instruction stringclasses 10
values | inputs dict | outputs stringclasses 10
values | meta dict |
|---|---|---|---|
Format your answer like this:
```python
<code>
```
Context:
{left_context}
Requirement: continue the body of only one function. Strictly adhere to Python indentation. Do not add unnecessary text or write other functions. Your generation will be inserted immediately after the context and run by tests. | {
"left_context": "import math\n\ndef compute_area(radius):\n \"\"\"Compute the area of a circle given the radius.\"\"\"\n"
} | ```python
if radius < 0:
raise ValueError("Radius cannot be negative")
return math.pi * radius ** 2
``` | {
"id": 1,
"repo": null,
"base_commit": null,
"gt": null,
"right_context": "print(compute_area(5))\n",
"left_context": null,
"image_name": null,
"build_command": null,
"test_command": null,
"fn": null,
"PASS_TO_PASS": null,
"FAIL_TO_PASS": null,
"intent": null,
"intent_type": null
} |
Given a context before a function:
```python
{left_context}
```
Generate the continuation of the **body** of one method, without the header. Important: Format your answer in a code block:
```python
<code>
```
Permanent indentation, as in Python. The function body will be inserted after the context and will be tested. | {
"left_context": "class Calculator:\n \"\"\"A simple calculator class.\"\"\"\n\n def add(self, a, b):\n \"\"\"Return the sum of two numbers.\"\"\"\n"
} | ```python
return a + b
``` | {
"id": 2,
"repo": null,
"base_commit": null,
"gt": null,
"right_context": "\n def multiply(self, a, b):\n \"\"\"Return the product of two numbers.\"\"\"\n return a * b\n",
"left_context": null,
"image_name": null,
"build_command": null,
"test_command": null,
"fn": null,
"PASS_TO_... |
Here is the beginning of the file:
{left_context}
Your entire answer should be in the block:
```python
<code>
```
Your task is to complete the body of one function. Do not write def s or comments. Use indentation for this function. Do not write any other functions. Your answer will be concatenated at the beginning of t... | {
"left_context": "def find_max(numbers):\n \"\"\"Find the maximum number in a list.\"\"\"\n"
} | ```python
if not numbers:
raise ValueError("List cannot be empty")
max_val = numbers[0]
for num in numbers:
if num > max_val:
max_val = num
return max_val
``` | {
"id": 3,
"repo": null,
"base_commit": null,
"gt": null,
"right_context": "print(find_max([1, 3, 7, 2]))\n",
"left_context": null,
"image_name": null,
"build_command": null,
"test_command": null,
"fn": null,
"PASS_TO_PASS": null,
"FAIL_TO_PASS": null,
"intent": null,
"intent_type": null
} |
Use the following code:
{left_context}
Now—just the implementation of the body of one function. Place the answer in the block:
```python
<code>
```
Indentation must be correct, signature is not required. Do not write any other functions. The answer will be inserted into the function and tested. | {
"left_context": "from dataclasses import dataclass\nfrom typing import Self\n\nfrom pysphinx.const import SECURITY_PARAMETER\nfrom pysphinx.crypto import compute_hmac_sha256\n\n\n@dataclass\nclass IntegrityHmac:\n \"\"\"\n This class represents a HMAC-SHA256 that can be used for integrity authentication.\n ... | ```python
if len(value) != self.SIZE:
raise ValueError("invalid length of HMAC", len(value))
self.value = value
``` | {
"id": 510,
"repo": "youngjoon-lee/pysphinx",
"base_commit": "d098530166e2669b59e5718bb0357886fd5d0013",
"gt": " if len(value) != self.SIZE:\n raise ValueError(\"invalid length of HMAC\", len(value))\n\n self.value = value\n",
"right_context": "\n @classmethod\n def compute(cls... |
Based on the following:
{left_context}
Format the result like this:
```python
<code>
```
Write the body of the missing function. No signature. Indentation is important—do not break the code structure. Do not write any other functions. Your answer will be joined to the context and run by tests. | {
"left_context": "\"\"\"\n# Concussion / shell state\n\nState of the Concussion shell. Contains the dictionary of local variables used\nby the REPL. Modifications to these locals are passed through to the REPL,\nallowing for programmatic modification of the REPL environment.\n\"\"\"\nfrom concussion import Concussio... | ```python
builtins = {}
for name in dir(shell_builtins):
object = getattr(shell_builtins, name)
if (
isinstance(object, type)
and issubclass(object, ConcussionBuiltin)
and object is not ConcussionBuiltin
):
builtins[name] = object()
re... | {
"id": 690,
"repo": "MiguelGuthridge/concussion",
"base_commit": "50161ef81dbb369e5af9e2bb3d5b782b125105f7",
"gt": " builtins = {}\n for name in dir(shell_builtins):\n object = getattr(shell_builtins, name)\n if (\n isinstance(object, type)\n and issubclass(object, Con... |
You see the code before def:
```python
{left_context}
```
Now continue the body of exactly one method. Just the body without the signature. The answer should be formatted in a block:
```python
<code>
```
Be sure to maintain the indentation. Do not write any other functions. The answer will be inserted into the function... | {
"left_context": "\"\"\"\nA module for superimposing text in the middle of progress bars\n\"\"\"\nimport shutil\nfrom tqdm import tqdm\nimport time\n\n\nclass TextBar(tqdm):\n \"\"\"\n A class which puts text in the middle of the tqdm progress bar\n Manages updates to set the bar format correctly\n \"\"\... | ```python
colours = TextBar.__colors_from_rgb_hex(self.colour)
return '\x1b[48;2;' + ';'.join(map(str, colours)) + 'm'
``` | {
"id": 848,
"repo": "TheHardew/compress_comics",
"base_commit": "ff70fbd9fdb4234588282fcfc4b5e443d6e721e5",
"gt": " colours = TextBar.__colors_from_rgb_hex(self.colour)\n return '\\x1b[48;2;' + ';'.join(map(str, colours)) + 'm'\n",
"right_context": "\n @staticmethod\n def reset_line():\n ... |
Here is the beginning of the code:
{left_context}
Continue the unfinished function—from the function body. Place the entire answer in the block:
```python
<code>
```
Python indentation must be precise. The signature and unnecessary parts are unnecessary. Do not write any other functions. The entire answer will be inse... | {
"left_context": "\ndef draw_text_with_end_coordinate(canvas, x_end, y, text, font_family='Helvetica', font_size=8):\n # Calculate the width of the text\n text_width = canvas.stringWidth(text, font_family, font_size)\n\n # Adjust the starting x-coordinate to place the text's end at x_end\n x_start = x_en... | ```python
resp = "{:,.2f}".format(float_value)
resp = resp.replace(",", "X").replace(".", ",").replace("X", ".")
currency = "$ " if include_currency else ""
return f'{currency}{resp}'
``` | {
"id": 315,
"repo": " /payroll_arg_reportes",
"base_commit": "057fb1a498d736fcfb6f5c922b62a14c50e4b202",
"gt": " resp = \"{:,.2f}\".format(float_value)\n resp = resp.replace(\",\", \"X\").replace(\".\", \",\").replace(\"X\", \".\")\n currency = \"$ \" if include_currency else \"\"\n\n return f'{cur... |
Given:
{left_context}
Generate the contents of the missing function (the function body). Strictly adhere to indentation, and omit def s and comments. Format your answer as follows:
```python
<code>
```
Do not write any other functions. The answer will be concatenated with the context and tested. | {
"left_context": "import os\nimport shutil\n\ndef sort_by_type(directory) -> bool:\n \"\"\"\n Sort files in a directory by their type.\n \n :param directory: The directory to sort.\n :return: True if the operation is successful, False otherwise.\n \"\"\"\n"
} | ```python
try:
# Sort files in a directory by their type
for item in os.listdir(directory):
# Check if item is a file
if os.path.isfile(os.path.join(directory, item)):
# Get the file type
file_type = item.split('.')[-1]
# Create... | {
"id": 869,
"repo": "ahmad-masud/File-Sorter",
"base_commit": "0ed475b1486017b562642a4809442eeb0ff15ac1",
"gt": " try:\n # Sort files in a directory by their type\n for item in os.listdir(directory):\n # Check if item is a file\n if os.path.isfile(os.path.join(directory, ... |
Source code:
{left_context}
Complete this unfinished function. Function body only. The answer should be in the following block:
```python
<code>
```
Permanent indentation, do not include the function name. Do not write any other functions. The answer will be inserted into the function and run by the tests. | {
"left_context": "import yfinance as yf\nimport matplotlib.pyplot as plt\n\ndef plot_data(ticker_symbol, period) -> bool:\n \"\"\"\n Plots the historical stock data for a given stock based on its ticker symbol and the period in years.\n \n :param ticker_symbol: The stock's ticker symbol as a string.\n ... | ```python
# Fetch historical stock data
ticker = yf.Ticker(ticker_symbol)
ticker_data = ticker.history(period=f'{period}y')
# Calculate Average
ticker_data['Average'] = (ticker_data['High'] + ticker_data['Low']) / 2
# Plot the historical stock data
plt.figure(figsize=(14, 7))
plt.plot(... | {
"id": 142,
"repo": "ahmad-masud/Quant-Market-Predictor",
"base_commit": "452911ff852bf2abc160abc100669be79cf5fd38",
"gt": " # Fetch historical stock data\n ticker = yf.Ticker(ticker_symbol)\n ticker_data = ticker.history(period=f'{period}y')\n\n # Calculate Average\n ticker_data['Average'] = (t... |
Continue the missing function, starting strictly with the body. Maintain Python indentation. Do not include the signature or write other functions
{left_context}
Your answer will be joined to the context and tested. Format the rest of the function body in a block:
```python
<code>
```
| {
"left_context": "\"\"\"Script Logger\"\"\"\n\nimport copy\nimport datetime\nimport inspect\nimport logging\nimport os\nfrom typing import List, Optional\n\nimport rich.box\nimport rich.console\nfrom rich.console import Console\nfrom rich.table import Table\nfrom rich.theme import Theme\n\nfrom slogpy.util import st... | ```python
if depth == 0:
return ""
return "-" * (depth * 2) + " "
``` | {
"id": 854,
"repo": "slogpy/slogpy",
"base_commit": "57d0ff1d33ff40b2ee842cbf70945236b2d8d626",
"gt": " if depth == 0:\n return \"\"\n return \"-\" * (depth * 2) + \" \"\n",
"right_context": "\n\ndef _get_logging_root_path():\n \"\"\"Get the directory we should log into\"\"\"\n root = os.g... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.