task_id string | source string | source_id string | solution_code string | test string | methods_info_json string | num_functions int64 | num_cross_deps int64 | difficulty_split string | nondeterminism_flags list | class_name string | variant int64 | instruction string | prompt_text string | target_text string | prompt_parse_ok bool | prompt_parse_error string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ClassEval_0 | FudanSELab/ClassEval | ClassEval_0 | import logging
import datetime
class AccessGatewayFilter:
def __init__(self):
pass
def filter(self, request):
request_uri = request['path']
method = request['method']
if self.is_start_with(request_uri):
return True
try:
token = self.get_jwt_u... | import unittest
class AccessGatewayFilterTestFilter(unittest.TestCase):
def test_filter_1(self):
agf = AccessGatewayFilter()
request = {'path': '/api/data', 'method': 'GET'}
res = agf.filter(request)
self.assertTrue(res)
def test_filter_2(self):
agf = AccessGatewayFilte... | [{"method_name": "filter", "method_description": "def filter(self, request):\n \"\"\"\n Filter the incoming request based on certain rules and conditions.\n :param request: dict, the incoming request details\n :return: bool, True if the request is allowed, False otherwise\n >>> filter... | 4 | 3 | mixed | [
"datetime.now"
] | AccessGatewayFilter | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This class is a filter used for accessing gateway filtering, primarily for authentication and access log recording."""
import logging
import datetime
class AccessGatewayFilter:
"""
This class is a filter used for accessing gateway filtering, primarily for authentication and access log recording.
"""
... | true | ||
ClassEval_0 | FudanSELab/ClassEval | ClassEval_0 | import logging
import datetime
class AccessGatewayFilter:
def __init__(self):
pass
def filter(self, request):
request_uri = request['path']
method = request['method']
if self.is_start_with(request_uri):
return True
try:
token = self.get_jwt_u... | import unittest
class AccessGatewayFilterTestFilter(unittest.TestCase):
def test_filter_1(self):
agf = AccessGatewayFilter()
request = {'path': '/api/data', 'method': 'GET'}
res = agf.filter(request)
self.assertTrue(res)
def test_filter_2(self):
agf = AccessGatewayFilte... | [{"method_name": "filter", "method_description": "def filter(self, request):\n \"\"\"\n Filter the incoming request based on certain rules and conditions.\n :param request: dict, the incoming request details\n :return: bool, True if the request is allowed, False otherwise\n >>> filter... | 4 | 3 | mixed | [
"datetime.now"
] | AccessGatewayFilter | 2 | Complete all missing function or method bodies. Return the complete Python file. | import logging
import datetime
class AccessGatewayFilter:
def __init__(self):
pass
def filter(self, request):
request_uri = request['path']
...
def is_start_with(self, request_uri):
start_with = ['/api', '/login']
...
def get_jwt_user(self, request):
... | true | ||
ClassEval_0 | FudanSELab/ClassEval | ClassEval_0 | import logging
import datetime
class AccessGatewayFilter:
def __init__(self):
pass
def filter(self, request):
request_uri = request['path']
method = request['method']
if self.is_start_with(request_uri):
return True
try:
token = self.get_jwt_u... | import unittest
class AccessGatewayFilterTestFilter(unittest.TestCase):
def test_filter_1(self):
agf = AccessGatewayFilter()
request = {'path': '/api/data', 'method': 'GET'}
res = agf.filter(request)
self.assertTrue(res)
def test_filter_2(self):
agf = AccessGatewayFilte... | [{"method_name": "filter", "method_description": "def filter(self, request):\n \"\"\"\n Filter the incoming request based on certain rules and conditions.\n :param request: dict, the incoming request details\n :return: bool, True if the request is allowed, False otherwise\n >>> filter... | 4 | 3 | mixed | [
"datetime.now"
] | AccessGatewayFilter | 3 | Implement the complete class. Return the complete Python file. | """This class is a filter used for accessing gateway filtering, primarily for authentication and access log recording.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `filter(self, request)`: Filter the incoming request based on certain rules and conditions.
- `is_start_with(sel... |
def __init__(self):
pass
def filter(self, request):
request_uri = request['path']
method = request['method']
if self.is_start_with(request_uri):
return True
try:
token = self.get_jwt_user(request)
user = token['user']
if u... | true | |
ClassEval_1 | FudanSELab/ClassEval | ClassEval_1 | import math
class AreaCalculator:
def __init__(self, radius):
self.radius = radius
def calculate_circle_area(self):
return math.pi * self.radius ** 2
def calculate_sphere_area(self):
return 4 * math.pi * self.radius ** 2
def calculate_cylinder_area(self, height):
re... | import unittest
class AreaCalculatorTestCalculateCircleArea(unittest.TestCase):
def test_calculate_circle_area(self):
areaCalculator = AreaCalculator(2)
self.assertAlmostEqual(12.56, areaCalculator.calculate_circle_area(), delta=0.01)
def test_calculate_circle_area_2(self):
areaCalculat... | [{"method_name": "calculate_circle_area", "method_description": "def calculate_circle_area(self):\n \"\"\"\n calculate the area of circle based on self.radius\n :return: area of circle, float\n >>> areaCalculator = AreaCalculator(2)\n >>> areaCalculator.calculate_circle_area()\n ... | 5 | 4 | sequential | [] | AreaCalculator | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus."""
import math
class AreaCalculator:
"""
This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus.
"""
def __init__(self,... | true | ||
ClassEval_1 | FudanSELab/ClassEval | ClassEval_1 | import math
class AreaCalculator:
def __init__(self, radius):
self.radius = radius
def calculate_circle_area(self):
return math.pi * self.radius ** 2
def calculate_sphere_area(self):
return 4 * math.pi * self.radius ** 2
def calculate_cylinder_area(self, height):
re... | import unittest
class AreaCalculatorTestCalculateCircleArea(unittest.TestCase):
def test_calculate_circle_area(self):
areaCalculator = AreaCalculator(2)
self.assertAlmostEqual(12.56, areaCalculator.calculate_circle_area(), delta=0.01)
def test_calculate_circle_area_2(self):
areaCalculat... | [{"method_name": "calculate_circle_area", "method_description": "def calculate_circle_area(self):\n \"\"\"\n calculate the area of circle based on self.radius\n :return: area of circle, float\n >>> areaCalculator = AreaCalculator(2)\n >>> areaCalculator.calculate_circle_area()\n ... | 5 | 4 | sequential | [] | AreaCalculator | 2 | Complete all missing function or method bodies. Return the complete Python file. | import math
class AreaCalculator:
def __init__(self, radius):
self.radius = radius
def calculate_circle_area(self):
return math.pi * self.radius ** 2
def calculate_sphere_area(self):
return 4 * math.pi * self.radius ** 2
def calculate_cylinder_area(self, height):
ret... | true | ||
ClassEval_1 | FudanSELab/ClassEval | ClassEval_1 | import math
class AreaCalculator:
def __init__(self, radius):
self.radius = radius
def calculate_circle_area(self):
return math.pi * self.radius ** 2
def calculate_sphere_area(self):
return 4 * math.pi * self.radius ** 2
def calculate_cylinder_area(self, height):
re... | import unittest
class AreaCalculatorTestCalculateCircleArea(unittest.TestCase):
def test_calculate_circle_area(self):
areaCalculator = AreaCalculator(2)
self.assertAlmostEqual(12.56, areaCalculator.calculate_circle_area(), delta=0.01)
def test_calculate_circle_area_2(self):
areaCalculat... | [{"method_name": "calculate_circle_area", "method_description": "def calculate_circle_area(self):\n \"\"\"\n calculate the area of circle based on self.radius\n :return: area of circle, float\n >>> areaCalculator = AreaCalculator(2)\n >>> areaCalculator.calculate_circle_area()\n ... | 5 | 4 | sequential | [] | AreaCalculator | 3 | Implement the complete class. Return the complete Python file. | """This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus.
Required methods (implement on the class; order is not specified):
- `__init__(self, radius)`
- `calculate_circle_area(self)`: calculate the area of circle based on self.radius
- `calculate_sphere_a... |
def __init__(self, radius):
self.radius = radius
def calculate_circle_area(self):
return math.pi * self.radius ** 2
def calculate_sphere_area(self):
return 4 * math.pi * self.radius ** 2
def calculate_cylinder_area(self, height):
return 2 * math.pi * self.radius * (se... | true | |
ClassEval_2 | FudanSELab/ClassEval | ClassEval_2 | class ArgumentParser:
def __init__(self):
self.arguments = {}
self.required = set()
self.types = {}
def parse_arguments(self, command_string):
args = command_string.split()[1:]
for i in range(len(args)):
arg = args[i]
if arg.startswith('--'):
... | import unittest
class ArgumentParserTestParseArguments(unittest.TestCase):
def setUp(self):
self.parser = ArgumentParser()
# key value arguments
def test_parse_arguments_1(self):
command_str = "script --name=John --age=25"
self.parser.add_argument("name")
self.parser.add_a... | [{"method_name": "parse_arguments", "method_description": "def parse_arguments(self, command_string):\n \"\"\"\n Parses the given command line argument string and invoke _convert_type to stores the parsed result in specific type in the arguments dictionary.\n Checks for missing required arguments, ... | 4 | 7 | sequential | [] | ArgumentParser | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class for parsing command line arguments to a dictionary."""
class ArgumentParser:
"""
This is a class for parsing command line arguments to a dictionary.
"""
def __init__(self):
"""Initialize the fields.
self.arguments is a dict that stores the args in a command line
self.requrie... | true | ||
ClassEval_2 | FudanSELab/ClassEval | ClassEval_2 | class ArgumentParser:
def __init__(self):
self.arguments = {}
self.required = set()
self.types = {}
def parse_arguments(self, command_string):
args = command_string.split()[1:]
for i in range(len(args)):
arg = args[i]
if arg.startswith('--'):
... | import unittest
class ArgumentParserTestParseArguments(unittest.TestCase):
def setUp(self):
self.parser = ArgumentParser()
# key value arguments
def test_parse_arguments_1(self):
command_str = "script --name=John --age=25"
self.parser.add_argument("name")
self.parser.add_a... | [{"method_name": "parse_arguments", "method_description": "def parse_arguments(self, command_string):\n \"\"\"\n Parses the given command line argument string and invoke _convert_type to stores the parsed result in specific type in the arguments dictionary.\n Checks for missing required arguments, ... | 4 | 7 | sequential | [] | ArgumentParser | 2 | Complete all missing function or method bodies. Return the complete Python file. | class ArgumentParser:
def __init__(self):
self.arguments = {}
self.required = set()
self.types = {}
def parse_arguments(self, command_string):
args = command_string.split()[1:]
...
def get_argument(self, key):
return self.arguments.get(key)
def add_arg... | true | ||
ClassEval_2 | FudanSELab/ClassEval | ClassEval_2 | class ArgumentParser:
def __init__(self):
self.arguments = {}
self.required = set()
self.types = {}
def parse_arguments(self, command_string):
args = command_string.split()[1:]
for i in range(len(args)):
arg = args[i]
if arg.startswith('--'):
... | import unittest
class ArgumentParserTestParseArguments(unittest.TestCase):
def setUp(self):
self.parser = ArgumentParser()
# key value arguments
def test_parse_arguments_1(self):
command_str = "script --name=John --age=25"
self.parser.add_argument("name")
self.parser.add_a... | [{"method_name": "parse_arguments", "method_description": "def parse_arguments(self, command_string):\n \"\"\"\n Parses the given command line argument string and invoke _convert_type to stores the parsed result in specific type in the arguments dictionary.\n Checks for missing required arguments, ... | 4 | 7 | sequential | [] | ArgumentParser | 3 | Implement the complete class. Return the complete Python file. | """This is a class for parsing command line arguments to a dictionary.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `parse_arguments(self, command_string)`: Parses the given command line argument string and invoke _convert_type to stores the parsed result in specific type in ... |
def __init__(self):
self.arguments = {}
self.required = set()
self.types = {}
def parse_arguments(self, command_string):
args = command_string.split()[1:]
for i in range(len(args)):
arg = args[i]
if arg.startswith('--'):
key_value... | true | |
ClassEval_3 | FudanSELab/ClassEval | ClassEval_3 | import itertools
class ArrangementCalculator:
def __init__(self, datas):
self.datas = datas
@staticmethod
def count(n, m=None):
if m is None or n == m:
return ArrangementCalculator.factorial(n)
else:
return ArrangementCalculator.factorial(n) // ArrangementC... | import unittest
class ArrangementCalculatorTestCount(unittest.TestCase):
def test_count_1(self):
res = ArrangementCalculator.count(5, 3)
self.assertEqual(res, 60)
def test_count_2(self):
res = ArrangementCalculator.count(4, 3)
self.assertEqual(res, 24)
def test_count_3(se... | [{"method_name": "count", "method_description": "def count(n, m=None):\n \"\"\"\n Counts the number of arrangements by choosing m items from n items (permutations).\n If m is not provided or n equals m, returns factorial(n).\n :param n: int, the total number of items.\n :param m: int,... | 5 | 5 | sequential | [] | ArrangementCalculator | 1 | Complete all missing function or method bodies. Return the complete Python file. | """The Arrangement class provides permutation calculations and selection operations for a given set of data elements."""
import itertools
class ArrangementCalculator:
"""
The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
"""
def __init__... | true | ||
ClassEval_3 | FudanSELab/ClassEval | ClassEval_3 | import itertools
class ArrangementCalculator:
def __init__(self, datas):
self.datas = datas
@staticmethod
def count(n, m=None):
if m is None or n == m:
return ArrangementCalculator.factorial(n)
else:
return ArrangementCalculator.factorial(n) // ArrangementC... | import unittest
class ArrangementCalculatorTestCount(unittest.TestCase):
def test_count_1(self):
res = ArrangementCalculator.count(5, 3)
self.assertEqual(res, 60)
def test_count_2(self):
res = ArrangementCalculator.count(4, 3)
self.assertEqual(res, 24)
def test_count_3(se... | [{"method_name": "count", "method_description": "def count(n, m=None):\n \"\"\"\n Counts the number of arrangements by choosing m items from n items (permutations).\n If m is not provided or n equals m, returns factorial(n).\n :param n: int, the total number of items.\n :param m: int,... | 5 | 5 | sequential | [] | ArrangementCalculator | 2 | Complete all missing function or method bodies. Return the complete Python file. | import itertools
class ArrangementCalculator:
def __init__(self, datas):
self.datas = datas
@staticmethod
def count(n, m=None):
if m is None or n == m:
return ArrangementCalculator.factorial(n)
else:
return ArrangementCalculator.factorial(n) // ArrangementC... | true | ||
ClassEval_3 | FudanSELab/ClassEval | ClassEval_3 | import itertools
class ArrangementCalculator:
def __init__(self, datas):
self.datas = datas
@staticmethod
def count(n, m=None):
if m is None or n == m:
return ArrangementCalculator.factorial(n)
else:
return ArrangementCalculator.factorial(n) // ArrangementC... | import unittest
class ArrangementCalculatorTestCount(unittest.TestCase):
def test_count_1(self):
res = ArrangementCalculator.count(5, 3)
self.assertEqual(res, 60)
def test_count_2(self):
res = ArrangementCalculator.count(4, 3)
self.assertEqual(res, 24)
def test_count_3(se... | [{"method_name": "count", "method_description": "def count(n, m=None):\n \"\"\"\n Counts the number of arrangements by choosing m items from n items (permutations).\n If m is not provided or n equals m, returns factorial(n).\n :param n: int, the total number of items.\n :param m: int,... | 5 | 5 | sequential | [] | ArrangementCalculator | 3 | Implement the complete class. Return the complete Python file. | """The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
Required methods (implement on the class; order is not specified):
- `__init__(self, datas)`
- `count(n, m=None)`: Counts the number of arrangements by choosing m items from n items (permutations).
- `... |
def __init__(self, datas):
self.datas = datas
@staticmethod
def count(n, m=None):
if m is None or n == m:
return ArrangementCalculator.factorial(n)
else:
return ArrangementCalculator.factorial(n) // ArrangementCalculator.factorial(n - m)
@staticmethod
... | true | |
ClassEval_4 | FudanSELab/ClassEval | ClassEval_4 | class AssessmentSystem:
def __init__(self):
self.students = {}
def add_student(self, name, grade, major):
self.students[name] = {'name': name, 'grade': grade, 'major': major, 'courses': {}}
def add_course_score(self, name, course, score):
if name in self.students:
self.... | import unittest
class AssessmentSystemTestAddStudent(unittest.TestCase):
def test_add_student(self):
assessment_system = AssessmentSystem()
assessment_system.add_student("Alice", 3, "Mathematics")
self.assertEqual(assessment_system.students["Alice"],
{'name': 'Alice... | [{"method_name": "add_student", "method_description": "def add_student(self, name, grade, major):\n \"\"\"\n Add a new student into self.students dict\n :param name: str, student name\n :param grade: int, student grade\n :param major: str, student major\n >>> system.add_student... | 6 | 7 | sequential | [] | AssessmentSystem | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses."""
class AssessmentSystem:
"""
This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other f... | true | ||
ClassEval_4 | FudanSELab/ClassEval | ClassEval_4 | class AssessmentSystem:
def __init__(self):
self.students = {}
def add_student(self, name, grade, major):
self.students[name] = {'name': name, 'grade': grade, 'major': major, 'courses': {}}
def add_course_score(self, name, course, score):
if name in self.students:
self.... | import unittest
class AssessmentSystemTestAddStudent(unittest.TestCase):
def test_add_student(self):
assessment_system = AssessmentSystem()
assessment_system.add_student("Alice", 3, "Mathematics")
self.assertEqual(assessment_system.students["Alice"],
{'name': 'Alice... | [{"method_name": "add_student", "method_description": "def add_student(self, name, grade, major):\n \"\"\"\n Add a new student into self.students dict\n :param name: str, student name\n :param grade: int, student grade\n :param major: str, student major\n >>> system.add_student... | 6 | 7 | sequential | [] | AssessmentSystem | 2 | Complete all missing function or method bodies. Return the complete Python file. | class AssessmentSystem:
def __init__(self):
self.students = {}
def add_student(self, name, grade, major):
self.students[name] = {'name': name, 'grade': grade, 'major': major, 'courses': {}}
def add_course_score(self, name, course, score):
if name in self.students:
self... | true | ||
ClassEval_4 | FudanSELab/ClassEval | ClassEval_4 | class AssessmentSystem:
def __init__(self):
self.students = {}
def add_student(self, name, grade, major):
self.students[name] = {'name': name, 'grade': grade, 'major': major, 'courses': {}}
def add_course_score(self, name, course, score):
if name in self.students:
self.... | import unittest
class AssessmentSystemTestAddStudent(unittest.TestCase):
def test_add_student(self):
assessment_system = AssessmentSystem()
assessment_system.add_student("Alice", 3, "Mathematics")
self.assertEqual(assessment_system.students["Alice"],
{'name': 'Alice... | [{"method_name": "add_student", "method_description": "def add_student(self, name, grade, major):\n \"\"\"\n Add a new student into self.students dict\n :param name: str, student name\n :param grade: int, student grade\n :param major: str, student major\n >>> system.add_student... | 6 | 7 | sequential | [] | AssessmentSystem | 3 | Implement the complete class. Return the complete Python file. | """This is a class as an student assessment system, which supports add student, add course score, calculate GPA, and other functions for students and courses.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `add_student(self, name, grade, major)`: Add a new student into self.stu... |
def __init__(self):
self.students = {}
def add_student(self, name, grade, major):
self.students[name] = {'name': name, 'grade': grade, 'major': major, 'courses': {}}
def add_course_score(self, name, course, score):
if name in self.students:
self.students[name]['courses... | true | |
ClassEval_5 | FudanSELab/ClassEval | ClassEval_5 | class AutomaticGuitarSimulator:
def __init__(self, text) -> None:
self.play_text = text
def interpret(self, display=False):
if not self.play_text.strip():
return []
else:
play_list = []
play_segs = self.play_text.split(" ")
for play_seg in... | import unittest
class AutomaticGuitarSimulatorTestInterpret(unittest.TestCase):
def test_interpret_1(self):
context = AutomaticGuitarSimulator("C53231323")
play_list = context.interpret()
self.assertEqual(play_list, [{'Chord': 'C', 'Tune': '53231323'}])
def test_interpret_2(self):
... | [{"method_name": "interpret", "method_description": "def interpret(self, display=False):\n \"\"\"\n Interpret the music score to be played\n :param display:Bool, representing whether to print the interpreted score\n :return: list of dict, The dict includes two fields, Chord and Tune, which are letters and n... | 2 | 2 | mixed | [] | AutomaticGuitarSimulator | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This class is an automatic guitar simulator that can interpret and play based on the input guitar sheet music."""
| true | ||
ClassEval_5 | FudanSELab/ClassEval | ClassEval_5 | class AutomaticGuitarSimulator:
def __init__(self, text) -> None:
self.play_text = text
def interpret(self, display=False):
if not self.play_text.strip():
return []
else:
play_list = []
play_segs = self.play_text.split(" ")
for play_seg in... | import unittest
class AutomaticGuitarSimulatorTestInterpret(unittest.TestCase):
def test_interpret_1(self):
context = AutomaticGuitarSimulator("C53231323")
play_list = context.interpret()
self.assertEqual(play_list, [{'Chord': 'C', 'Tune': '53231323'}])
def test_interpret_2(self):
... | [{"method_name": "interpret", "method_description": "def interpret(self, display=False):\n \"\"\"\n Interpret the music score to be played\n :param display:Bool, representing whether to print the interpreted score\n :return: list of dict, The dict includes two fields, Chord and Tune, which are letters and n... | 2 | 2 | mixed | [] | AutomaticGuitarSimulator | 2 | Complete all missing function or method bodies. Return the complete Python file. | class AutomaticGuitarSimulator:
def __init__(self, text) -> None:
self.play_text = text
def interpret(self, display=False):
if not self.play_text.strip():
return []
else:
play_list = []
play_segs = self.play_text.split(' ')
for play_seg i... | true | ||
ClassEval_5 | FudanSELab/ClassEval | ClassEval_5 | class AutomaticGuitarSimulator:
def __init__(self, text) -> None:
self.play_text = text
def interpret(self, display=False):
if not self.play_text.strip():
return []
else:
play_list = []
play_segs = self.play_text.split(" ")
for play_seg in... | import unittest
class AutomaticGuitarSimulatorTestInterpret(unittest.TestCase):
def test_interpret_1(self):
context = AutomaticGuitarSimulator("C53231323")
play_list = context.interpret()
self.assertEqual(play_list, [{'Chord': 'C', 'Tune': '53231323'}])
def test_interpret_2(self):
... | [{"method_name": "interpret", "method_description": "def interpret(self, display=False):\n \"\"\"\n Interpret the music score to be played\n :param display:Bool, representing whether to print the interpreted score\n :return: list of dict, The dict includes two fields, Chord and Tune, which are letters and n... | 2 | 2 | mixed | [] | AutomaticGuitarSimulator | 3 | Implement the complete class. Return the complete Python file. | """This class is an automatic guitar simulator that can interpret and play based on the input guitar sheet music.
Required methods (implement on the class; order is not specified):
- `__init__(self, text) -> None`
- `interpret(self, display=False)`: Interpret the music score to be played
- `display(self, key, value)`:... |
def __init__(self, text) -> None:
self.play_text = text
def interpret(self, display=False):
if not self.play_text.strip():
return []
else:
play_list = []
play_segs = self.play_text.split(' ')
for play_seg in play_segs:
pos... | true | |
ClassEval_6 | FudanSELab/ClassEval | ClassEval_6 | class AvgPartition:
def __init__(self, lst, limit):
self.lst = lst
self.limit = limit
def setNum(self):
size = len(self.lst) // self.limit
remainder = len(self.lst) % self.limit
return size, remainder
def get(self, index):
size, remainder = self.set... | import unittest
class AvgPartitionTestSetNum(unittest.TestCase):
def test_setNum(self):
a = AvgPartition([1, 2, 3, 4], 2)
self.assertEqual(a.setNum(), (2, 0))
def test_setNum_2(self):
a = AvgPartition([1, 2, 3, 4, 5], 2)
self.assertEqual(a.setNum(), (2, 1))
def test_setNum... | [{"method_name": "setNum", "method_description": "def setNum(self):\n \"\"\"\n Calculate the size of each block and the remainder of the division.\n :return: the size of each block and the remainder of the division, tuple.\n >>> a = AvgPartition([1, 2, 3, 4], 2)\n >>> a.setNum()\n ... | 2 | 4 | sequential | [] | AvgPartition | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class that partitions the given list into different blocks by specifying the number of partitions, with each block having a uniformly distributed length."""
class AvgPartition:
"""
This is a class that partitions the given list into different blocks by specifying the number of partitions, with eac... | true | ||
ClassEval_6 | FudanSELab/ClassEval | ClassEval_6 | class AvgPartition:
def __init__(self, lst, limit):
self.lst = lst
self.limit = limit
def setNum(self):
size = len(self.lst) // self.limit
remainder = len(self.lst) % self.limit
return size, remainder
def get(self, index):
size, remainder = self.set... | import unittest
class AvgPartitionTestSetNum(unittest.TestCase):
def test_setNum(self):
a = AvgPartition([1, 2, 3, 4], 2)
self.assertEqual(a.setNum(), (2, 0))
def test_setNum_2(self):
a = AvgPartition([1, 2, 3, 4, 5], 2)
self.assertEqual(a.setNum(), (2, 1))
def test_setNum... | [{"method_name": "setNum", "method_description": "def setNum(self):\n \"\"\"\n Calculate the size of each block and the remainder of the division.\n :return: the size of each block and the remainder of the division, tuple.\n >>> a = AvgPartition([1, 2, 3, 4], 2)\n >>> a.setNum()\n ... | 2 | 4 | sequential | [] | AvgPartition | 2 | Complete all missing function or method bodies. Return the complete Python file. | class AvgPartition:
def __init__(self, lst, limit):
self.lst = lst
self.limit = limit
def setNum(self):
size = len(self.lst) // self.limit
...
def get(self, index):
size, remainder = self.setNum()
...
| true | ||
ClassEval_6 | FudanSELab/ClassEval | ClassEval_6 | class AvgPartition:
def __init__(self, lst, limit):
self.lst = lst
self.limit = limit
def setNum(self):
size = len(self.lst) // self.limit
remainder = len(self.lst) % self.limit
return size, remainder
def get(self, index):
size, remainder = self.set... | import unittest
class AvgPartitionTestSetNum(unittest.TestCase):
def test_setNum(self):
a = AvgPartition([1, 2, 3, 4], 2)
self.assertEqual(a.setNum(), (2, 0))
def test_setNum_2(self):
a = AvgPartition([1, 2, 3, 4, 5], 2)
self.assertEqual(a.setNum(), (2, 1))
def test_setNum... | [{"method_name": "setNum", "method_description": "def setNum(self):\n \"\"\"\n Calculate the size of each block and the remainder of the division.\n :return: the size of each block and the remainder of the division, tuple.\n >>> a = AvgPartition([1, 2, 3, 4], 2)\n >>> a.setNum()\n ... | 2 | 4 | sequential | [] | AvgPartition | 3 | Implement the complete class. Return the complete Python file. | """This is a class that partitions the given list into different blocks by specifying the number of partitions, with each block having a uniformly distributed length.
Required methods (implement on the class; order is not specified):
- `__init__(self, lst, limit)`
- `setNum(self)`: Calculate the size of each block and... |
def __init__(self, lst, limit):
self.lst = lst
self.limit = limit
def setNum(self):
size = len(self.lst) // self.limit
remainder = len(self.lst) % self.limit
return (size, remainder)
def get(self, index):
size, remainder = self.setNum()
start = inde... | true | |
ClassEval_7 | FudanSELab/ClassEval | ClassEval_7 | class BalancedBrackets:
def __init__(self, expr):
self.stack = []
self.left_brackets = ["(", "{", "["]
self.right_brackets = [")", "}", "]"]
self.expr = expr
def clear_expr(self):
self.expr = ''.join(c for c in self.expr if (c in self.left_brackets or c in self.right_bra... | import unittest
class BalancedBracketsTestClearExpr(unittest.TestCase):
def test_clear_expr(self):
b = BalancedBrackets("a(b)c")
b.clear_expr()
self.assertEqual(b.expr, "()")
def test_clear_expr_2(self):
b = BalancedBrackets("a(b){c}")
b.clear_expr()
self.asser... | [{"method_name": "clear_expr", "method_description": "def clear_expr(self):\n \"\"\"\n Clears the expression of all characters that are not brackets.\n >>> b = BalancedBrackets(\"a(b)c\")\n >>> b.clear_expr()\n >>> b.expr\n '()'\n\n \"\"\"", "test_class": "BalancedBracke... | 2 | 7 | sequential | [] | BalancedBrackets | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class that checks for bracket matching"""
class BalancedBrackets:
"""
This is a class that checks for bracket matching
"""
def __init__(self, expr):
"""Initializes the class with an expression.
:param expr: The expression to check for balanced brackets,str."""
...
def... | true | ||
ClassEval_7 | FudanSELab/ClassEval | ClassEval_7 | class BalancedBrackets:
def __init__(self, expr):
self.stack = []
self.left_brackets = ["(", "{", "["]
self.right_brackets = [")", "}", "]"]
self.expr = expr
def clear_expr(self):
self.expr = ''.join(c for c in self.expr if (c in self.left_brackets or c in self.right_bra... | import unittest
class BalancedBracketsTestClearExpr(unittest.TestCase):
def test_clear_expr(self):
b = BalancedBrackets("a(b)c")
b.clear_expr()
self.assertEqual(b.expr, "()")
def test_clear_expr_2(self):
b = BalancedBrackets("a(b){c}")
b.clear_expr()
self.asser... | [{"method_name": "clear_expr", "method_description": "def clear_expr(self):\n \"\"\"\n Clears the expression of all characters that are not brackets.\n >>> b = BalancedBrackets(\"a(b)c\")\n >>> b.clear_expr()\n >>> b.expr\n '()'\n\n \"\"\"", "test_class": "BalancedBracke... | 2 | 7 | sequential | [] | BalancedBrackets | 2 | Complete all missing function or method bodies. Return the complete Python file. | class BalancedBrackets:
def __init__(self, expr):
self.stack = []
self.left_brackets = ['(', '{', '[']
self.right_brackets = [')', '}', ']']
self.expr = expr
def clear_expr(self):
self.expr = ''.join((c for c in self.expr if c in self.left_brackets or c in self.right_br... | true | ||
ClassEval_7 | FudanSELab/ClassEval | ClassEval_7 | class BalancedBrackets:
def __init__(self, expr):
self.stack = []
self.left_brackets = ["(", "{", "["]
self.right_brackets = [")", "}", "]"]
self.expr = expr
def clear_expr(self):
self.expr = ''.join(c for c in self.expr if (c in self.left_brackets or c in self.right_bra... | import unittest
class BalancedBracketsTestClearExpr(unittest.TestCase):
def test_clear_expr(self):
b = BalancedBrackets("a(b)c")
b.clear_expr()
self.assertEqual(b.expr, "()")
def test_clear_expr_2(self):
b = BalancedBrackets("a(b){c}")
b.clear_expr()
self.asser... | [{"method_name": "clear_expr", "method_description": "def clear_expr(self):\n \"\"\"\n Clears the expression of all characters that are not brackets.\n >>> b = BalancedBrackets(\"a(b)c\")\n >>> b.clear_expr()\n >>> b.expr\n '()'\n\n \"\"\"", "test_class": "BalancedBracke... | 2 | 7 | sequential | [] | BalancedBrackets | 3 | Implement the complete class. Return the complete Python file. | """This is a class that checks for bracket matching
Required methods (implement on the class; order is not specified):
- `__init__(self, expr)`
- `clear_expr(self)`: Clears the expression of all characters that are not brackets.
- `check_balanced_brackets(self)`: Checks if the expression has balanced brackets."""
cla... |
def __init__(self, expr):
self.stack = []
self.left_brackets = ['(', '{', '[']
self.right_brackets = [')', '}', ']']
self.expr = expr
def clear_expr(self):
self.expr = ''.join((c for c in self.expr if c in self.left_brackets or c in self.right_brackets))
def check_... | true | |
ClassEval_8 | FudanSELab/ClassEval | ClassEval_8 | class BankAccount:
def __init__(self, balance=0):
self.balance = balance
def deposit(self, amount):
if amount < 0:
raise ValueError("Invalid amount")
self.balance += amount
return self.balance
def withdraw(self, amount):
if amount < 0:
raise ... | import unittest
class BankAccountTestDeposit(unittest.TestCase):
def test_deposit(self):
account1 = BankAccount()
ret = account1.deposit(1000)
self.assertEqual(ret, 1000)
def test_deposit_2(self):
account1 = BankAccount()
account1.deposit(1000)
ret = account1.d... | [{"method_name": "deposit", "method_description": "def deposit(self, amount):\n \"\"\"\n Deposits a certain amount into the account, increasing the account balance, return the current account balance.\n If amount is negative, raise a ValueError(\"Invalid amount\").\n :param amount: int\n ... | 4 | 5 | sequential | [] | BankAccount | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class as a bank account system, which supports deposit money, withdraw money, view balance, and transfer money."""
class BankAccount:
"""
This is a class as a bank account system, which supports deposit money, withdraw money, view balance, and transfer money.
"""
def __init__(self, balanc... | true | ||
ClassEval_8 | FudanSELab/ClassEval | ClassEval_8 | class BankAccount:
def __init__(self, balance=0):
self.balance = balance
def deposit(self, amount):
if amount < 0:
raise ValueError("Invalid amount")
self.balance += amount
return self.balance
def withdraw(self, amount):
if amount < 0:
raise ... | import unittest
class BankAccountTestDeposit(unittest.TestCase):
def test_deposit(self):
account1 = BankAccount()
ret = account1.deposit(1000)
self.assertEqual(ret, 1000)
def test_deposit_2(self):
account1 = BankAccount()
account1.deposit(1000)
ret = account1.d... | [{"method_name": "deposit", "method_description": "def deposit(self, amount):\n \"\"\"\n Deposits a certain amount into the account, increasing the account balance, return the current account balance.\n If amount is negative, raise a ValueError(\"Invalid amount\").\n :param amount: int\n ... | 4 | 5 | sequential | [] | BankAccount | 2 | Complete all missing function or method bodies. Return the complete Python file. | class BankAccount:
def __init__(self, balance=0):
self.balance = balance
def deposit(self, amount):
if amount < 0:
raise ValueError('Invalid amount')
...
def withdraw(self, amount):
if amount < 0:
raise ValueError('Invalid amount')
...
... | true | ||
ClassEval_8 | FudanSELab/ClassEval | ClassEval_8 | class BankAccount:
def __init__(self, balance=0):
self.balance = balance
def deposit(self, amount):
if amount < 0:
raise ValueError("Invalid amount")
self.balance += amount
return self.balance
def withdraw(self, amount):
if amount < 0:
raise ... | import unittest
class BankAccountTestDeposit(unittest.TestCase):
def test_deposit(self):
account1 = BankAccount()
ret = account1.deposit(1000)
self.assertEqual(ret, 1000)
def test_deposit_2(self):
account1 = BankAccount()
account1.deposit(1000)
ret = account1.d... | [{"method_name": "deposit", "method_description": "def deposit(self, amount):\n \"\"\"\n Deposits a certain amount into the account, increasing the account balance, return the current account balance.\n If amount is negative, raise a ValueError(\"Invalid amount\").\n :param amount: int\n ... | 4 | 5 | sequential | [] | BankAccount | 3 | Implement the complete class. Return the complete Python file. | """This is a class as a bank account system, which supports deposit money, withdraw money, view balance, and transfer money.
Required methods (implement on the class; order is not specified):
- `__init__(self, balance=0)`
- `deposit(self, amount)`: Deposits a certain amount into the account, increasing the account bal... |
def __init__(self, balance=0):
self.balance = balance
def deposit(self, amount):
if amount < 0:
raise ValueError('Invalid amount')
self.balance += amount
return self.balance
def withdraw(self, amount):
if amount < 0:
raise ValueError('Invali... | true | |
ClassEval_9 | FudanSELab/ClassEval | ClassEval_9 | class BigNumCalculator:
@staticmethod
def add(num1, num2):
max_length = max(len(num1), len(num2))
num1 = num1.zfill(max_length)
num2 = num2.zfill(max_length)
carry = 0
result = []
for i in range(max_length - 1, -1, -1):
digit_sum = int(num1[i]) + int(... | import unittest
class BigNumCalculatorTestAdd(unittest.TestCase):
def test_add(self):
bigNum = BigNumCalculator()
self.assertEqual(bigNum.add("12345678901234567890", "98765432109876543210"), "111111111011111111100")
def test_add_2(self):
bigNum = BigNumCalculator()
self.assertE... | [{"method_name": "add", "method_description": "def add(num1, num2):\n \"\"\"\n Adds two big numbers.\n :param num1: The first number to add,str.\n :param num2: The second number to add,str.\n :return: The sum of the two numbers,str.\n >>> bigNum = BigNumCalculator()\n >>... | 3 | 0 | parallel | [] | BigNumCalculator | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class that implements big number calculations, including adding, subtracting and multiplying."""
class BigNumCalculator:
"""
This is a class that implements big number calculations, including adding, subtracting and multiplying.
"""
@staticmethod
def add(num1, num2):
"""Adds t... | true | ||
ClassEval_9 | FudanSELab/ClassEval | ClassEval_9 | class BigNumCalculator:
@staticmethod
def add(num1, num2):
max_length = max(len(num1), len(num2))
num1 = num1.zfill(max_length)
num2 = num2.zfill(max_length)
carry = 0
result = []
for i in range(max_length - 1, -1, -1):
digit_sum = int(num1[i]) + int(... | import unittest
class BigNumCalculatorTestAdd(unittest.TestCase):
def test_add(self):
bigNum = BigNumCalculator()
self.assertEqual(bigNum.add("12345678901234567890", "98765432109876543210"), "111111111011111111100")
def test_add_2(self):
bigNum = BigNumCalculator()
self.assertE... | [{"method_name": "add", "method_description": "def add(num1, num2):\n \"\"\"\n Adds two big numbers.\n :param num1: The first number to add,str.\n :param num2: The second number to add,str.\n :return: The sum of the two numbers,str.\n >>> bigNum = BigNumCalculator()\n >>... | 3 | 0 | parallel | [] | BigNumCalculator | 2 | Complete all missing function or method bodies. Return the complete Python file. | class BigNumCalculator:
@staticmethod
def add(num1, num2):
max_length = max(len(num1), len(num2))
num1 = num1.zfill(max_length)
...
@staticmethod
def subtract(num1, num2):
if len(num1) < len(num2):
num1, num2 = (num2, num1)
negative = True
... | true | ||
ClassEval_9 | FudanSELab/ClassEval | ClassEval_9 | class BigNumCalculator:
@staticmethod
def add(num1, num2):
max_length = max(len(num1), len(num2))
num1 = num1.zfill(max_length)
num2 = num2.zfill(max_length)
carry = 0
result = []
for i in range(max_length - 1, -1, -1):
digit_sum = int(num1[i]) + int(... | import unittest
class BigNumCalculatorTestAdd(unittest.TestCase):
def test_add(self):
bigNum = BigNumCalculator()
self.assertEqual(bigNum.add("12345678901234567890", "98765432109876543210"), "111111111011111111100")
def test_add_2(self):
bigNum = BigNumCalculator()
self.assertE... | [{"method_name": "add", "method_description": "def add(num1, num2):\n \"\"\"\n Adds two big numbers.\n :param num1: The first number to add,str.\n :param num2: The second number to add,str.\n :return: The sum of the two numbers,str.\n >>> bigNum = BigNumCalculator()\n >>... | 3 | 0 | parallel | [] | BigNumCalculator | 3 | Implement the complete class. Return the complete Python file. | """This is a class that implements big number calculations, including adding, subtracting and multiplying.
Required methods (implement on the class; order is not specified):
- `add(num1, num2)`: Adds two big numbers.
- `subtract(...)`: Subtracts two big numbers.
- `multiply(...)`: Multiplies two big numbers."""
class... |
@staticmethod
def add(num1, num2):
max_length = max(len(num1), len(num2))
num1 = num1.zfill(max_length)
num2 = num2.zfill(max_length)
carry = 0
result = []
for i in range(max_length - 1, -1, -1):
digit_sum = int(num1[i]) + int(num2[i]) + carry
... | true | |
ClassEval_10 | FudanSELab/ClassEval | ClassEval_10 | class BinaryDataProcessor:
def __init__(self, binary_string):
self.binary_string = binary_string
self.clean_non_binary_chars()
def clean_non_binary_chars(self):
self.binary_string = ''.join(filter(lambda x: x in '01', self.binary_string))
def calculate_binary_info(self):
ze... | import unittest
class BinaryDataProcessorTestCleanNonBinaryChars(unittest.TestCase):
def test_clean_non_binary_chars(self):
bdp = BinaryDataProcessor("01101000daf3e4r01100101011011000110110001101111")
self.assertEqual(bdp.binary_string, "0110100001100101011011000110110001101111")
def test_clea... | [{"method_name": "clean_non_binary_chars", "method_description": "def clean_non_binary_chars(self):\n \"\"\"\n Clean the binary string by removing all non 0 or 1 characters.\n >>> bdp = BinaryDataProcessor(\"01101000daf3e4r01100101011011000110110001101111\")\n >>> bdp.clean_non_binary_chars(... | 4 | 4 | sequential | [] | BinaryDataProcessor | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class used to process binary data, which includes functions such as clearing non 0 or 1 characters, counting binary string information, and converting to corresponding strings based on different encoding methods."""
class BinaryDataProcessor:
"""
This is a class used to process binary data, which ... | true | ||
ClassEval_10 | FudanSELab/ClassEval | ClassEval_10 | class BinaryDataProcessor:
def __init__(self, binary_string):
self.binary_string = binary_string
self.clean_non_binary_chars()
def clean_non_binary_chars(self):
self.binary_string = ''.join(filter(lambda x: x in '01', self.binary_string))
def calculate_binary_info(self):
ze... | import unittest
class BinaryDataProcessorTestCleanNonBinaryChars(unittest.TestCase):
def test_clean_non_binary_chars(self):
bdp = BinaryDataProcessor("01101000daf3e4r01100101011011000110110001101111")
self.assertEqual(bdp.binary_string, "0110100001100101011011000110110001101111")
def test_clea... | [{"method_name": "clean_non_binary_chars", "method_description": "def clean_non_binary_chars(self):\n \"\"\"\n Clean the binary string by removing all non 0 or 1 characters.\n >>> bdp = BinaryDataProcessor(\"01101000daf3e4r01100101011011000110110001101111\")\n >>> bdp.clean_non_binary_chars(... | 4 | 4 | sequential | [] | BinaryDataProcessor | 2 | Complete all missing function or method bodies. Return the complete Python file. | class BinaryDataProcessor:
def __init__(self, binary_string):
self.binary_string = binary_string
self.clean_non_binary_chars()
def clean_non_binary_chars(self):
self.binary_string = ''.join(filter(lambda x: x in '01', self.binary_string))
def calculate_binary_info(self):
z... | true | ||
ClassEval_10 | FudanSELab/ClassEval | ClassEval_10 | class BinaryDataProcessor:
def __init__(self, binary_string):
self.binary_string = binary_string
self.clean_non_binary_chars()
def clean_non_binary_chars(self):
self.binary_string = ''.join(filter(lambda x: x in '01', self.binary_string))
def calculate_binary_info(self):
ze... | import unittest
class BinaryDataProcessorTestCleanNonBinaryChars(unittest.TestCase):
def test_clean_non_binary_chars(self):
bdp = BinaryDataProcessor("01101000daf3e4r01100101011011000110110001101111")
self.assertEqual(bdp.binary_string, "0110100001100101011011000110110001101111")
def test_clea... | [{"method_name": "clean_non_binary_chars", "method_description": "def clean_non_binary_chars(self):\n \"\"\"\n Clean the binary string by removing all non 0 or 1 characters.\n >>> bdp = BinaryDataProcessor(\"01101000daf3e4r01100101011011000110110001101111\")\n >>> bdp.clean_non_binary_chars(... | 4 | 4 | sequential | [] | BinaryDataProcessor | 3 | Implement the complete class. Return the complete Python file. | """This is a class used to process binary data, which includes functions such as clearing non 0 or 1 characters, counting binary string information, and converting to corresponding strings based on different encoding methods.
Required methods (implement on the class; order is not specified):
- `__init__(self, binary_s... |
def __init__(self, binary_string):
self.binary_string = binary_string
self.clean_non_binary_chars()
def clean_non_binary_chars(self):
self.binary_string = ''.join(filter(lambda x: x in '01', self.binary_string))
def calculate_binary_info(self):
zeroes_count = self.binary_s... | true | |
ClassEval_11 | FudanSELab/ClassEval | ClassEval_11 | class BitStatusUtil:
@staticmethod
def add(states, stat):
BitStatusUtil.check([states, stat])
return states | stat
@staticmethod
def has(states, stat):
BitStatusUtil.check([states, stat])
return (states & stat) == stat
@staticmethod
def remove(states, stat):
... | import unittest
class BitStatusUtilTestAdd(unittest.TestCase):
def test_add(self):
bit_status_util = BitStatusUtil()
self.assertEqual(bit_status_util.add(2, 4), 6)
def test_add_2(self):
bit_status_util = BitStatusUtil()
self.assertEqual(bit_status_util.add(2, 0), 2)
def t... | [{"method_name": "add", "method_description": "def add(states, stat):\n \"\"\"\n Add a status to the current status,and check the parameters wheather they are legal.\n :param states: Current status,int.\n :param stat: Status to be added,int.\n :return: The status after adding the stat... | 4 | 4 | sequential | [] | BitStatusUtil | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a utility class that provides methods for manipulating and checking status using bitwise operations."""
class BitStatusUtil:
"""
This is a utility class that provides methods for manipulating and checking status using bitwise operations.
"""
@staticmethod
def add(states, stat):
... | true | ||
ClassEval_11 | FudanSELab/ClassEval | ClassEval_11 | class BitStatusUtil:
@staticmethod
def add(states, stat):
BitStatusUtil.check([states, stat])
return states | stat
@staticmethod
def has(states, stat):
BitStatusUtil.check([states, stat])
return (states & stat) == stat
@staticmethod
def remove(states, stat):
... | import unittest
class BitStatusUtilTestAdd(unittest.TestCase):
def test_add(self):
bit_status_util = BitStatusUtil()
self.assertEqual(bit_status_util.add(2, 4), 6)
def test_add_2(self):
bit_status_util = BitStatusUtil()
self.assertEqual(bit_status_util.add(2, 0), 2)
def t... | [{"method_name": "add", "method_description": "def add(states, stat):\n \"\"\"\n Add a status to the current status,and check the parameters wheather they are legal.\n :param states: Current status,int.\n :param stat: Status to be added,int.\n :return: The status after adding the stat... | 4 | 4 | sequential | [] | BitStatusUtil | 2 | Complete all missing function or method bodies. Return the complete Python file. | class BitStatusUtil:
@staticmethod
def add(states, stat):
BitStatusUtil.check([states, stat])
...
@staticmethod
def has(states, stat):
BitStatusUtil.check([states, stat])
...
@staticmethod
def remove(states, stat):
BitStatusUtil.check([states, stat])
... | true | ||
ClassEval_11 | FudanSELab/ClassEval | ClassEval_11 | class BitStatusUtil:
@staticmethod
def add(states, stat):
BitStatusUtil.check([states, stat])
return states | stat
@staticmethod
def has(states, stat):
BitStatusUtil.check([states, stat])
return (states & stat) == stat
@staticmethod
def remove(states, stat):
... | import unittest
class BitStatusUtilTestAdd(unittest.TestCase):
def test_add(self):
bit_status_util = BitStatusUtil()
self.assertEqual(bit_status_util.add(2, 4), 6)
def test_add_2(self):
bit_status_util = BitStatusUtil()
self.assertEqual(bit_status_util.add(2, 0), 2)
def t... | [{"method_name": "add", "method_description": "def add(states, stat):\n \"\"\"\n Add a status to the current status,and check the parameters wheather they are legal.\n :param states: Current status,int.\n :param stat: Status to be added,int.\n :return: The status after adding the stat... | 4 | 4 | sequential | [] | BitStatusUtil | 3 | Implement the complete class. Return the complete Python file. | """This is a utility class that provides methods for manipulating and checking status using bitwise operations.
Required methods (implement on the class; order is not specified):
- `add(states, stat)`: Add a status to the current status,and check the parameters wheather they are legal.
- `has(...)`: Check if the curre... |
@staticmethod
def add(states, stat):
BitStatusUtil.check([states, stat])
return states | stat
@staticmethod
def has(states, stat):
BitStatusUtil.check([states, stat])
return states & stat == stat
@staticmethod
def remove(states, stat):
BitStatusUtil.che... | true | |
ClassEval_12 | FudanSELab/ClassEval | ClassEval_12 | import random
class BlackjackGame:
def __init__(self):
self.deck = self.create_deck()
self.player_hand = []
self.dealer_hand = []
def create_deck(self):
deck = []
suits = ['S', 'C', 'D', 'H']
ranks = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q',... | import unittest
class BlackjackGameTestCreateDeck(unittest.TestCase):
def setUp(self):
self.blackjackGame = BlackjackGame()
self.deck = self.blackjackGame.deck
def test_create_deck_1(self):
self.assertEqual(len(self.deck), 52)
def test_create_deck_2(self):
suits = ['S', 'C... | [{"method_name": "create_deck", "method_description": "def create_deck(self):\n \"\"\"\n Create a deck of 52 cards, which stores 52 rondom order poker with the Jokers removed.\n :return: a list of 52 rondom order poker with the Jokers removed, format is ['AS', '2S', ...].\n >>> black_jack_ga... | 3 | 1 | mixed | [
"random"
] | BlackjackGame | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class representing a game of blackjack, which includes creating a deck, calculating the value of a hand, and determine the winner based on the hand values of the player and dealer."""
import random
class BlackjackGame:
"""
This is a class representing a game of blackjack, which includes creating a... | true | ||
ClassEval_12 | FudanSELab/ClassEval | ClassEval_12 | import random
class BlackjackGame:
def __init__(self):
self.deck = self.create_deck()
self.player_hand = []
self.dealer_hand = []
def create_deck(self):
deck = []
suits = ['S', 'C', 'D', 'H']
ranks = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q',... | import unittest
class BlackjackGameTestCreateDeck(unittest.TestCase):
def setUp(self):
self.blackjackGame = BlackjackGame()
self.deck = self.blackjackGame.deck
def test_create_deck_1(self):
self.assertEqual(len(self.deck), 52)
def test_create_deck_2(self):
suits = ['S', 'C... | [{"method_name": "create_deck", "method_description": "def create_deck(self):\n \"\"\"\n Create a deck of 52 cards, which stores 52 rondom order poker with the Jokers removed.\n :return: a list of 52 rondom order poker with the Jokers removed, format is ['AS', '2S', ...].\n >>> black_jack_ga... | 3 | 1 | mixed | [
"random"
] | BlackjackGame | 2 | Complete all missing function or method bodies. Return the complete Python file. | import random
class BlackjackGame:
def __init__(self):
self.deck = self.create_deck()
self.player_hand = []
self.dealer_hand = []
def create_deck(self):
deck = []
suits = ['S', 'C', 'D', 'H']
...
def calculate_hand_value(self, hand):
value = 0
... | true | ||
ClassEval_12 | FudanSELab/ClassEval | ClassEval_12 | import random
class BlackjackGame:
def __init__(self):
self.deck = self.create_deck()
self.player_hand = []
self.dealer_hand = []
def create_deck(self):
deck = []
suits = ['S', 'C', 'D', 'H']
ranks = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q',... | import unittest
class BlackjackGameTestCreateDeck(unittest.TestCase):
def setUp(self):
self.blackjackGame = BlackjackGame()
self.deck = self.blackjackGame.deck
def test_create_deck_1(self):
self.assertEqual(len(self.deck), 52)
def test_create_deck_2(self):
suits = ['S', 'C... | [{"method_name": "create_deck", "method_description": "def create_deck(self):\n \"\"\"\n Create a deck of 52 cards, which stores 52 rondom order poker with the Jokers removed.\n :return: a list of 52 rondom order poker with the Jokers removed, format is ['AS', '2S', ...].\n >>> black_jack_ga... | 3 | 1 | mixed | [
"random"
] | BlackjackGame | 3 | Implement the complete class. Return the complete Python file. | """This is a class representing a game of blackjack, which includes creating a deck, calculating the value of a hand, and determine the winner based on the hand values of the player and dealer.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `create_deck(self)`: Create a deck of... |
def __init__(self):
self.deck = self.create_deck()
self.player_hand = []
self.dealer_hand = []
def create_deck(self):
deck = []
suits = ['S', 'C', 'D', 'H']
ranks = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']
for suit in suits:
... | true | |
ClassEval_13 | FudanSELab/ClassEval | ClassEval_13 | class BookManagement:
def __init__(self):
self.inventory = {}
def add_book(self, title, quantity=1):
if title in self.inventory:
self.inventory[title] += quantity
else:
self.inventory[title] = quantity
def remove_book(self, title, quantity):
if title... | import unittest
class BookManagementTestAddBook(unittest.TestCase):
def test_add_book_1(self):
bookManagement = BookManagement()
bookManagement.add_book("book1")
self.assertEqual({"book1": 1}, bookManagement.inventory)
def test_add_book_2(self):
bookManagement = BookManagement... | [{"method_name": "add_book", "method_description": "def add_book(self, title, quantity=1):\n \"\"\"\n Add one or several books to inventory which is sorted by book title.\n :param title: str, the book title\n :param quantity: int, default value is 1.\n \"\"\"", "test_class": "BookMana... | 4 | 4 | sequential | [] | BookManagement | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class as managing books system, which supports to add and remove books from the inventory dict, view the inventory, and check the quantity of a specific book."""
class BookManagement:
"""
This is a class as managing books system, which supports to add and remove books from the inventory dict, view... | true | ||
ClassEval_13 | FudanSELab/ClassEval | ClassEval_13 | class BookManagement:
def __init__(self):
self.inventory = {}
def add_book(self, title, quantity=1):
if title in self.inventory:
self.inventory[title] += quantity
else:
self.inventory[title] = quantity
def remove_book(self, title, quantity):
if title... | import unittest
class BookManagementTestAddBook(unittest.TestCase):
def test_add_book_1(self):
bookManagement = BookManagement()
bookManagement.add_book("book1")
self.assertEqual({"book1": 1}, bookManagement.inventory)
def test_add_book_2(self):
bookManagement = BookManagement... | [{"method_name": "add_book", "method_description": "def add_book(self, title, quantity=1):\n \"\"\"\n Add one or several books to inventory which is sorted by book title.\n :param title: str, the book title\n :param quantity: int, default value is 1.\n \"\"\"", "test_class": "BookMana... | 4 | 4 | sequential | [] | BookManagement | 2 | Complete all missing function or method bodies. Return the complete Python file. | class BookManagement:
def __init__(self):
self.inventory = {}
def add_book(self, title, quantity=1):
if title in self.inventory:
self.inventory[title] += quantity
else:
self.inventory[title] = quantity
def remove_book(self, title, quantity):
if titl... | true | ||
ClassEval_13 | FudanSELab/ClassEval | ClassEval_13 | class BookManagement:
def __init__(self):
self.inventory = {}
def add_book(self, title, quantity=1):
if title in self.inventory:
self.inventory[title] += quantity
else:
self.inventory[title] = quantity
def remove_book(self, title, quantity):
if title... | import unittest
class BookManagementTestAddBook(unittest.TestCase):
def test_add_book_1(self):
bookManagement = BookManagement()
bookManagement.add_book("book1")
self.assertEqual({"book1": 1}, bookManagement.inventory)
def test_add_book_2(self):
bookManagement = BookManagement... | [{"method_name": "add_book", "method_description": "def add_book(self, title, quantity=1):\n \"\"\"\n Add one or several books to inventory which is sorted by book title.\n :param title: str, the book title\n :param quantity: int, default value is 1.\n \"\"\"", "test_class": "BookMana... | 4 | 4 | sequential | [] | BookManagement | 3 | Implement the complete class. Return the complete Python file. | """This is a class as managing books system, which supports to add and remove books from the inventory dict, view the inventory, and check the quantity of a specific book.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `add_book(self, title, quantity=1)`: Add one or several boo... |
def __init__(self):
self.inventory = {}
def add_book(self, title, quantity=1):
if title in self.inventory:
self.inventory[title] += quantity
else:
self.inventory[title] = quantity
def remove_book(self, title, quantity):
if title not in self.inventor... | true | |
ClassEval_14 | FudanSELab/ClassEval | ClassEval_14 | import sqlite3
class BookManagementDB:
def __init__(self, db_name):
self.connection = sqlite3.connect(db_name)
self.cursor = self.connection.cursor()
self.create_table()
def create_table(self):
self.cursor.execute('''
CREATE TABLE IF NOT EXISTS books (
... | import unittest
import os
class BookManagementDBTestCreateTable(unittest.TestCase):
def setUp(self):
self.db_name = "test.db"
self.db = BookManagementDB(self.db_name)
self.connection = sqlite3.connect(self.db_name)
self.cursor = self.connection.cursor()
def test_create_table_1... | [{"method_name": "create_table", "method_description": "def create_table(self):\n \"\"\"\n Creates the book table in the database if it does not already exist.\n >>> book_db = BookManagementDB(\"test.db\")\n >>> book_db.create_table()\n \"\"\"", "test_class": "BookManagementDBTestCrea... | 6 | 11 | sequential | [] | BookManagementDB | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a database class as a book management system, used to handle the operations of adding, removing, updating, and searching books."""
import sqlite3
class BookManagementDB:
"""
This is a database class as a book management system, used to handle the operations of adding, removing, updating, and searchi... | true | ||
ClassEval_14 | FudanSELab/ClassEval | ClassEval_14 | import sqlite3
class BookManagementDB:
def __init__(self, db_name):
self.connection = sqlite3.connect(db_name)
self.cursor = self.connection.cursor()
self.create_table()
def create_table(self):
self.cursor.execute('''
CREATE TABLE IF NOT EXISTS books (
... | import unittest
import os
class BookManagementDBTestCreateTable(unittest.TestCase):
def setUp(self):
self.db_name = "test.db"
self.db = BookManagementDB(self.db_name)
self.connection = sqlite3.connect(self.db_name)
self.cursor = self.connection.cursor()
def test_create_table_1... | [{"method_name": "create_table", "method_description": "def create_table(self):\n \"\"\"\n Creates the book table in the database if it does not already exist.\n >>> book_db = BookManagementDB(\"test.db\")\n >>> book_db.create_table()\n \"\"\"", "test_class": "BookManagementDBTestCrea... | 6 | 11 | sequential | [] | BookManagementDB | 2 | Complete all missing function or method bodies. Return the complete Python file. | import sqlite3
class BookManagementDB:
def __init__(self, db_name):
self.connection = sqlite3.connect(db_name)
self.cursor = self.connection.cursor()
self.create_table()
def create_table(self):
self.cursor.execute('\n CREATE TABLE IF NOT EXISTS books (\n ... | true | ||
ClassEval_14 | FudanSELab/ClassEval | ClassEval_14 | import sqlite3
class BookManagementDB:
def __init__(self, db_name):
self.connection = sqlite3.connect(db_name)
self.cursor = self.connection.cursor()
self.create_table()
def create_table(self):
self.cursor.execute('''
CREATE TABLE IF NOT EXISTS books (
... | import unittest
import os
class BookManagementDBTestCreateTable(unittest.TestCase):
def setUp(self):
self.db_name = "test.db"
self.db = BookManagementDB(self.db_name)
self.connection = sqlite3.connect(self.db_name)
self.cursor = self.connection.cursor()
def test_create_table_1... | [{"method_name": "create_table", "method_description": "def create_table(self):\n \"\"\"\n Creates the book table in the database if it does not already exist.\n >>> book_db = BookManagementDB(\"test.db\")\n >>> book_db.create_table()\n \"\"\"", "test_class": "BookManagementDBTestCrea... | 6 | 11 | sequential | [] | BookManagementDB | 3 | Implement the complete class. Return the complete Python file. | """This is a database class as a book management system, used to handle the operations of adding, removing, updating, and searching books.
Required methods (implement on the class; order is not specified):
- `__init__(self, db_name)`
- `create_table(self)`: Creates the book table in the database if it does not already... |
def __init__(self, db_name):
self.connection = sqlite3.connect(db_name)
self.cursor = self.connection.cursor()
self.create_table()
def create_table(self):
self.cursor.execute('\n CREATE TABLE IF NOT EXISTS books (\n id INTEGER PRIMARY KEY,\n ... | true | |
ClassEval_15 | FudanSELab/ClassEval | ClassEval_15 | class BoyerMooreSearch:
def __init__(self, text, pattern):
self.text, self.pattern = text, pattern
self.textLen, self.patLen = len(text), len(pattern)
def match_in_pattern(self, char):
for i in range(self.patLen - 1, -1, -1):
if char == self.pattern[i]:
retur... | import unittest
class BoyerMooreSearchTestMatchInPattern(unittest.TestCase):
def test_match_in_pattern(self):
boyerMooreSearch = BoyerMooreSearch("ABAABA", "AB")
self.assertEqual(boyerMooreSearch.match_in_pattern("A"), 0)
def test_match_in_pattern_2(self):
boyerMooreSearch = BoyerMoore... | [{"method_name": "match_in_pattern", "method_description": "def match_in_pattern(self, char):\n \"\"\"\n Finds the rightmost occurrence of a character in the pattern.\n :param char: The character to be searched for, str.\n :return: The index of the rightmost occurrence of the character in th... | 3 | 10 | sequential | [] | BoyerMooreSearch | 1 | Complete all missing function or method bodies. Return the complete Python file. | """his is a class that implements the Boyer-Moore algorithm for string searching, which is used to find occurrences of a pattern within a given text."""
class BoyerMooreSearch:
"""
his is a class that implements the Boyer-Moore algorithm for string searching, which is used to find occurrences of a pattern with... | true | ||
ClassEval_15 | FudanSELab/ClassEval | ClassEval_15 | class BoyerMooreSearch:
def __init__(self, text, pattern):
self.text, self.pattern = text, pattern
self.textLen, self.patLen = len(text), len(pattern)
def match_in_pattern(self, char):
for i in range(self.patLen - 1, -1, -1):
if char == self.pattern[i]:
retur... | import unittest
class BoyerMooreSearchTestMatchInPattern(unittest.TestCase):
def test_match_in_pattern(self):
boyerMooreSearch = BoyerMooreSearch("ABAABA", "AB")
self.assertEqual(boyerMooreSearch.match_in_pattern("A"), 0)
def test_match_in_pattern_2(self):
boyerMooreSearch = BoyerMoore... | [{"method_name": "match_in_pattern", "method_description": "def match_in_pattern(self, char):\n \"\"\"\n Finds the rightmost occurrence of a character in the pattern.\n :param char: The character to be searched for, str.\n :return: The index of the rightmost occurrence of the character in th... | 3 | 10 | sequential | [] | BoyerMooreSearch | 2 | Complete all missing function or method bodies. Return the complete Python file. | class BoyerMooreSearch:
def __init__(self, text, pattern):
self.text, self.pattern = (text, pattern)
self.textLen, self.patLen = (len(text), len(pattern))
def match_in_pattern(self, char):
for i in range(self.patLen - 1, -1, -1):
if char == self.pattern[i]:
... | true | ||
ClassEval_15 | FudanSELab/ClassEval | ClassEval_15 | class BoyerMooreSearch:
def __init__(self, text, pattern):
self.text, self.pattern = text, pattern
self.textLen, self.patLen = len(text), len(pattern)
def match_in_pattern(self, char):
for i in range(self.patLen - 1, -1, -1):
if char == self.pattern[i]:
retur... | import unittest
class BoyerMooreSearchTestMatchInPattern(unittest.TestCase):
def test_match_in_pattern(self):
boyerMooreSearch = BoyerMooreSearch("ABAABA", "AB")
self.assertEqual(boyerMooreSearch.match_in_pattern("A"), 0)
def test_match_in_pattern_2(self):
boyerMooreSearch = BoyerMoore... | [{"method_name": "match_in_pattern", "method_description": "def match_in_pattern(self, char):\n \"\"\"\n Finds the rightmost occurrence of a character in the pattern.\n :param char: The character to be searched for, str.\n :return: The index of the rightmost occurrence of the character in th... | 3 | 10 | sequential | [] | BoyerMooreSearch | 3 | Implement the complete class. Return the complete Python file. | """his is a class that implements the Boyer-Moore algorithm for string searching, which is used to find occurrences of a pattern within a given text.
Required methods (implement on the class; order is not specified):
- `__init__(self, text, pattern)`
- `match_in_pattern(self, char)`: Finds the rightmost occurrence of ... |
def __init__(self, text, pattern):
self.text, self.pattern = (text, pattern)
self.textLen, self.patLen = (len(text), len(pattern))
def match_in_pattern(self, char):
for i in range(self.patLen - 1, -1, -1):
if char == self.pattern[i]:
return i
return ... | true | |
ClassEval_16 | FudanSELab/ClassEval | ClassEval_16 | class Calculator:
def __init__(self):
self.operators = {
'+': lambda x, y: x + y,
'-': lambda x, y: x - y,
'*': lambda x, y: x * y,
'/': lambda x, y: x / y,
'^': lambda x, y: x ** y
}
def calculate(self, expression):
operand_st... | import unittest
class CalculatorTestCalculate(unittest.TestCase):
def test_calculate_1(self):
calculator = Calculator()
res = calculator.calculate('1+2')
self.assertEqual(res, 3)
def test_calculate_2(self):
calculator = Calculator()
res = calculator.calculate('1+2*3')
... | [{"method_name": "calculate", "method_description": "def calculate(self, expression):\n \"\"\"\n Calculate the value of a given expression\n :param expression: string, given expression\n :return:If successful, returns the value of the expression; otherwise, returns None\n >>> calculat... | 3 | 3 | sequential | [] | Calculator | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class for a calculator, capable of performing basic arithmetic calculations on numerical expressions using the operators +, -, *, /, and ^ (exponentiation)."""
class Calculator:
"""
This is a class for a calculator, capable of performing basic arithmetic calculations on numerical expressions using... | true | ||
ClassEval_16 | FudanSELab/ClassEval | ClassEval_16 | class Calculator:
def __init__(self):
self.operators = {
'+': lambda x, y: x + y,
'-': lambda x, y: x - y,
'*': lambda x, y: x * y,
'/': lambda x, y: x / y,
'^': lambda x, y: x ** y
}
def calculate(self, expression):
operand_st... | import unittest
class CalculatorTestCalculate(unittest.TestCase):
def test_calculate_1(self):
calculator = Calculator()
res = calculator.calculate('1+2')
self.assertEqual(res, 3)
def test_calculate_2(self):
calculator = Calculator()
res = calculator.calculate('1+2*3')
... | [{"method_name": "calculate", "method_description": "def calculate(self, expression):\n \"\"\"\n Calculate the value of a given expression\n :param expression: string, given expression\n :return:If successful, returns the value of the expression; otherwise, returns None\n >>> calculat... | 3 | 3 | sequential | [] | Calculator | 2 | Complete all missing function or method bodies. Return the complete Python file. | class Calculator:
def __init__(self):
self.operators = {'+': lambda x, y: x + y, '-': lambda x, y: x - y, '*': lambda x, y: x * y, '/': lambda x, y: x / y, '^': lambda x, y: x ** y}
def calculate(self, expression):
operand_stack = []
operator_stack = []
...
def precedence(... | true | ||
ClassEval_16 | FudanSELab/ClassEval | ClassEval_16 | class Calculator:
def __init__(self):
self.operators = {
'+': lambda x, y: x + y,
'-': lambda x, y: x - y,
'*': lambda x, y: x * y,
'/': lambda x, y: x / y,
'^': lambda x, y: x ** y
}
def calculate(self, expression):
operand_st... | import unittest
class CalculatorTestCalculate(unittest.TestCase):
def test_calculate_1(self):
calculator = Calculator()
res = calculator.calculate('1+2')
self.assertEqual(res, 3)
def test_calculate_2(self):
calculator = Calculator()
res = calculator.calculate('1+2*3')
... | [{"method_name": "calculate", "method_description": "def calculate(self, expression):\n \"\"\"\n Calculate the value of a given expression\n :param expression: string, given expression\n :return:If successful, returns the value of the expression; otherwise, returns None\n >>> calculat... | 3 | 3 | sequential | [] | Calculator | 3 | Implement the complete class. Return the complete Python file. | """This is a class for a calculator, capable of performing basic arithmetic calculations on numerical expressions using the operators +, -, *, /, and ^ (exponentiation).
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `calculate(self, expression)`: Calculate the value of a given... |
def __init__(self):
self.operators = {'+': lambda x, y: x + y, '-': lambda x, y: x - y, '*': lambda x, y: x * y, '/': lambda x, y: x / y, '^': lambda x, y: x ** y}
def calculate(self, expression):
operand_stack = []
operator_stack = []
num_buffer = ''
for char in expres... | true | |
ClassEval_17 | FudanSELab/ClassEval | ClassEval_17 | from datetime import datetime, timedelta
class CalendarUtil:
def __init__(self):
self.events = []
def add_event(self, event):
self.events.append(event)
def remove_event(self, event):
if event in self.events:
self.events.remove(event)
def get_events(self, date):
... | import unittest
from datetime import datetime
class CalendarTestAddEvent(unittest.TestCase):
def test_add_event(self):
calendar = CalendarUtil()
calendar.add_event({'date': datetime(2023, 1, 1, 0, 0), 'start_time': datetime(2023, 1, 1, 0, 0),
'end_time': datetime(2023, ... | [{"method_name": "add_event", "method_description": "def add_event(self, event):\n \"\"\"\n Add an event to the calendar.\n :param event: The event to be added to the calendar,dict.\n >>> calendar = CalendarUtil()\n >>> calendar.add_event({'date': datetime(2023, 1, 1, 0, 0), 'start_ti... | 6 | 6 | sequential | [
"datetime.now"
] | CalendarUtil | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class as CalendarUtil that provides functionalities to manage calendar events, schedule appointments, and perform conflict checks."""
from datetime import datetime, timedelta
class CalendarUtil:
"""
This is a class as CalendarUtil that provides functionalities to manage calendar events, schedule a... | true | ||
ClassEval_17 | FudanSELab/ClassEval | ClassEval_17 | from datetime import datetime, timedelta
class CalendarUtil:
def __init__(self):
self.events = []
def add_event(self, event):
self.events.append(event)
def remove_event(self, event):
if event in self.events:
self.events.remove(event)
def get_events(self, date):
... | import unittest
from datetime import datetime
class CalendarTestAddEvent(unittest.TestCase):
def test_add_event(self):
calendar = CalendarUtil()
calendar.add_event({'date': datetime(2023, 1, 1, 0, 0), 'start_time': datetime(2023, 1, 1, 0, 0),
'end_time': datetime(2023, ... | [{"method_name": "add_event", "method_description": "def add_event(self, event):\n \"\"\"\n Add an event to the calendar.\n :param event: The event to be added to the calendar,dict.\n >>> calendar = CalendarUtil()\n >>> calendar.add_event({'date': datetime(2023, 1, 1, 0, 0), 'start_ti... | 6 | 6 | sequential | [
"datetime.now"
] | CalendarUtil | 2 | Complete all missing function or method bodies. Return the complete Python file. | from datetime import datetime, timedelta
class CalendarUtil:
def __init__(self):
self.events = []
def add_event(self, event):
self.events.append(event)
def remove_event(self, event):
if event in self.events:
self.events.remove(event)
def get_events(self, date):
... | true | ||
ClassEval_17 | FudanSELab/ClassEval | ClassEval_17 | from datetime import datetime, timedelta
class CalendarUtil:
def __init__(self):
self.events = []
def add_event(self, event):
self.events.append(event)
def remove_event(self, event):
if event in self.events:
self.events.remove(event)
def get_events(self, date):
... | import unittest
from datetime import datetime
class CalendarTestAddEvent(unittest.TestCase):
def test_add_event(self):
calendar = CalendarUtil()
calendar.add_event({'date': datetime(2023, 1, 1, 0, 0), 'start_time': datetime(2023, 1, 1, 0, 0),
'end_time': datetime(2023, ... | [{"method_name": "add_event", "method_description": "def add_event(self, event):\n \"\"\"\n Add an event to the calendar.\n :param event: The event to be added to the calendar,dict.\n >>> calendar = CalendarUtil()\n >>> calendar.add_event({'date': datetime(2023, 1, 1, 0, 0), 'start_ti... | 6 | 6 | sequential | [
"datetime.now"
] | CalendarUtil | 3 | Implement the complete class. Return the complete Python file. | """This is a class as CalendarUtil that provides functionalities to manage calendar events, schedule appointments, and perform conflict checks.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `add_event(self, event)`: Add an event to the calendar.
- `remove_event(self, event)`: ... |
def __init__(self):
self.events = []
def add_event(self, event):
self.events.append(event)
def remove_event(self, event):
if event in self.events:
self.events.remove(event)
def get_events(self, date):
events_on_date = []
for event in self.events:
... | true | |
ClassEval_18 | FudanSELab/ClassEval | ClassEval_18 | class CamelCaseMap:
def __init__(self):
self._data = {}
def __getitem__(self, key):
return self._data[self._convert_key(key)]
def __setitem__(self, key, value):
self._data[self._convert_key(key)] = value
def __delitem__(self, key):
del self._data[self._convert_key(key)... | import unittest
class CamelCaseMapTestGetitem(unittest.TestCase):
def test_getitem_1(self):
camelize_map = CamelCaseMap()
camelize_map['first_name'] = 'John'
self.assertEqual(camelize_map.__getitem__('first_name'), 'John')
def test_getitem_2(self):
camelize_map = CamelCaseMap(... | [{"method_name": "__getitem__", "method_description": "def __getitem__(self, key):\n \"\"\"\n Return the value corresponding to the key\n :param key:str\n :return:str,the value corresponding to the key\n >>> camelize_map = CamelCaseMap()\n >>> camelize_map['first_name'] = 'John... | 7 | 9 | sequential | [] | CamelCaseMap | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a custom class that allows keys to be in camel case style by converting them from underscore style, which provides dictionary-like functionality."""
class CamelCaseMap:
"""
This is a custom class that allows keys to be in camel case style by converting them from underscore style, which provides dict... | true | ||
ClassEval_18 | FudanSELab/ClassEval | ClassEval_18 | class CamelCaseMap:
def __init__(self):
self._data = {}
def __getitem__(self, key):
return self._data[self._convert_key(key)]
def __setitem__(self, key, value):
self._data[self._convert_key(key)] = value
def __delitem__(self, key):
del self._data[self._convert_key(key)... | import unittest
class CamelCaseMapTestGetitem(unittest.TestCase):
def test_getitem_1(self):
camelize_map = CamelCaseMap()
camelize_map['first_name'] = 'John'
self.assertEqual(camelize_map.__getitem__('first_name'), 'John')
def test_getitem_2(self):
camelize_map = CamelCaseMap(... | [{"method_name": "__getitem__", "method_description": "def __getitem__(self, key):\n \"\"\"\n Return the value corresponding to the key\n :param key:str\n :return:str,the value corresponding to the key\n >>> camelize_map = CamelCaseMap()\n >>> camelize_map['first_name'] = 'John... | 7 | 9 | sequential | [] | CamelCaseMap | 2 | Complete all missing function or method bodies. Return the complete Python file. | class CamelCaseMap:
def __init__(self):
self._data = {}
def __getitem__(self, key):
return self._data[self._convert_key(key)]
def __setitem__(self, key, value):
self._data[self._convert_key(key)] = value
def __delitem__(self, key):
del self._data[self._convert_key(key... | true | ||
ClassEval_18 | FudanSELab/ClassEval | ClassEval_18 | class CamelCaseMap:
def __init__(self):
self._data = {}
def __getitem__(self, key):
return self._data[self._convert_key(key)]
def __setitem__(self, key, value):
self._data[self._convert_key(key)] = value
def __delitem__(self, key):
del self._data[self._convert_key(key)... | import unittest
class CamelCaseMapTestGetitem(unittest.TestCase):
def test_getitem_1(self):
camelize_map = CamelCaseMap()
camelize_map['first_name'] = 'John'
self.assertEqual(camelize_map.__getitem__('first_name'), 'John')
def test_getitem_2(self):
camelize_map = CamelCaseMap(... | [{"method_name": "__getitem__", "method_description": "def __getitem__(self, key):\n \"\"\"\n Return the value corresponding to the key\n :param key:str\n :return:str,the value corresponding to the key\n >>> camelize_map = CamelCaseMap()\n >>> camelize_map['first_name'] = 'John... | 7 | 9 | sequential | [] | CamelCaseMap | 3 | Implement the complete class. Return the complete Python file. | """This is a custom class that allows keys to be in camel case style by converting them from underscore style, which provides dictionary-like functionality.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `__getitem__(self, key)`: Return the value corresponding to the key
- `__s... |
def __init__(self):
self._data = {}
def __getitem__(self, key):
return self._data[self._convert_key(key)]
def __setitem__(self, key, value):
self._data[self._convert_key(key)] = value
def __delitem__(self, key):
del self._data[self._convert_key(key)]
def __iter__... | true | |
ClassEval_19 | FudanSELab/ClassEval | ClassEval_19 | class ChandrasekharSieve:
def __init__(self, n):
self.n = n
self.primes = self.generate_primes()
def generate_primes(self):
if self.n < 2:
return []
sieve = [True] * (self.n + 1)
sieve[0] = sieve[1] = False
p = 2
while p * p <= self.n:
... | import unittest
class ChandrasekharSieveTestGeneratePrimes(unittest.TestCase):
def test_generate_primes_1(self):
cs = ChandrasekharSieve(20)
res = cs.generate_primes()
self.assertEqual(res, [2, 3, 5, 7, 11, 13, 17, 19])
def test_generate_primes_2(self):
cs = ChandrasekharSieve... | [{"method_name": "generate_primes", "method_description": "def generate_primes(self):\n \"\"\"\n Generate prime numbers up to the specified limit using the Chandrasekhar sieve algorithm.\n :return: list, a list of prime numbers\n >>> cs = ChandrasekharSieve(20)\n >>> cs.generate_prime... | 2 | 2 | sequential | [] | ChandrasekharSieve | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class that uses the Chandrasekhar's Sieve method to find all prime numbers within the range"""
class ChandrasekharSieve:
"""
This is a class that uses the Chandrasekhar's Sieve method to find all prime numbers within the range
"""
def __init__(self, n):
"""Initialize the Chandrase... | true | ||
ClassEval_19 | FudanSELab/ClassEval | ClassEval_19 | class ChandrasekharSieve:
def __init__(self, n):
self.n = n
self.primes = self.generate_primes()
def generate_primes(self):
if self.n < 2:
return []
sieve = [True] * (self.n + 1)
sieve[0] = sieve[1] = False
p = 2
while p * p <= self.n:
... | import unittest
class ChandrasekharSieveTestGeneratePrimes(unittest.TestCase):
def test_generate_primes_1(self):
cs = ChandrasekharSieve(20)
res = cs.generate_primes()
self.assertEqual(res, [2, 3, 5, 7, 11, 13, 17, 19])
def test_generate_primes_2(self):
cs = ChandrasekharSieve... | [{"method_name": "generate_primes", "method_description": "def generate_primes(self):\n \"\"\"\n Generate prime numbers up to the specified limit using the Chandrasekhar sieve algorithm.\n :return: list, a list of prime numbers\n >>> cs = ChandrasekharSieve(20)\n >>> cs.generate_prime... | 2 | 2 | sequential | [] | ChandrasekharSieve | 2 | Complete all missing function or method bodies. Return the complete Python file. | class ChandrasekharSieve:
def __init__(self, n):
self.n = n
self.primes = self.generate_primes()
def generate_primes(self):
if self.n < 2:
return []
sieve = [True] * (self.n + 1)
...
def get_primes(self):
return self.primes
| true | ||
ClassEval_19 | FudanSELab/ClassEval | ClassEval_19 | class ChandrasekharSieve:
def __init__(self, n):
self.n = n
self.primes = self.generate_primes()
def generate_primes(self):
if self.n < 2:
return []
sieve = [True] * (self.n + 1)
sieve[0] = sieve[1] = False
p = 2
while p * p <= self.n:
... | import unittest
class ChandrasekharSieveTestGeneratePrimes(unittest.TestCase):
def test_generate_primes_1(self):
cs = ChandrasekharSieve(20)
res = cs.generate_primes()
self.assertEqual(res, [2, 3, 5, 7, 11, 13, 17, 19])
def test_generate_primes_2(self):
cs = ChandrasekharSieve... | [{"method_name": "generate_primes", "method_description": "def generate_primes(self):\n \"\"\"\n Generate prime numbers up to the specified limit using the Chandrasekhar sieve algorithm.\n :return: list, a list of prime numbers\n >>> cs = ChandrasekharSieve(20)\n >>> cs.generate_prime... | 2 | 2 | sequential | [] | ChandrasekharSieve | 3 | Implement the complete class. Return the complete Python file. | """This is a class that uses the Chandrasekhar's Sieve method to find all prime numbers within the range
Required methods (implement on the class; order is not specified):
- `__init__(self, n)`
- `generate_primes(self)`: Generate prime numbers up to the specified limit using the Chandrasekhar sieve algorithm.
- `get_p... |
def __init__(self, n):
self.n = n
self.primes = self.generate_primes()
def generate_primes(self):
if self.n < 2:
return []
sieve = [True] * (self.n + 1)
sieve[0] = sieve[1] = False
p = 2
while p * p <= self.n:
if sieve[p]:
... | true | |
ClassEval_20 | FudanSELab/ClassEval | ClassEval_20 | from datetime import datetime
class Chat:
def __init__(self):
self.users = {}
def add_user(self, username):
if username in self.users:
return False
else:
self.users[username] = []
return True
def remove_user(self, username):
if username ... | import unittest
class ChatTestAddUser(unittest.TestCase):
def test_add_user(self):
chat = Chat()
self.assertEqual(chat.add_user('John'), True)
self.assertEqual(chat.users, {'John': []})
def test_add_user_2(self):
chat = Chat()
chat.users = {'John': []}
self.asser... | [{"method_name": "add_user", "method_description": "def add_user(self, username):\n \"\"\"\n Add a new user to the Chat.\n :param username: The user's name, str.\n :return: If the user is already in the Chat, returns False, otherwise, returns True.\n >>> chat = Chat()\n >>> cha... | 4 | 4 | sequential | [
"datetime.now"
] | Chat | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a chat class with the functions of adding users, removing users, sending messages, and obtaining messages."""
from datetime import datetime
class Chat:
"""
This is a chat class with the functions of adding users, removing users, sending messages, and obtaining messages.
"""
def __init__(sel... | true | ||
ClassEval_20 | FudanSELab/ClassEval | ClassEval_20 | from datetime import datetime
class Chat:
def __init__(self):
self.users = {}
def add_user(self, username):
if username in self.users:
return False
else:
self.users[username] = []
return True
def remove_user(self, username):
if username ... | import unittest
class ChatTestAddUser(unittest.TestCase):
def test_add_user(self):
chat = Chat()
self.assertEqual(chat.add_user('John'), True)
self.assertEqual(chat.users, {'John': []})
def test_add_user_2(self):
chat = Chat()
chat.users = {'John': []}
self.asser... | [{"method_name": "add_user", "method_description": "def add_user(self, username):\n \"\"\"\n Add a new user to the Chat.\n :param username: The user's name, str.\n :return: If the user is already in the Chat, returns False, otherwise, returns True.\n >>> chat = Chat()\n >>> cha... | 4 | 4 | sequential | [
"datetime.now"
] | Chat | 2 | Complete all missing function or method bodies. Return the complete Python file. | from datetime import datetime
class Chat:
def __init__(self):
self.users = {}
def add_user(self, username):
if username in self.users:
return False
else:
self.users[username] = []
return True
def remove_user(self, username):
if username... | true | ||
ClassEval_20 | FudanSELab/ClassEval | ClassEval_20 | from datetime import datetime
class Chat:
def __init__(self):
self.users = {}
def add_user(self, username):
if username in self.users:
return False
else:
self.users[username] = []
return True
def remove_user(self, username):
if username ... | import unittest
class ChatTestAddUser(unittest.TestCase):
def test_add_user(self):
chat = Chat()
self.assertEqual(chat.add_user('John'), True)
self.assertEqual(chat.users, {'John': []})
def test_add_user_2(self):
chat = Chat()
chat.users = {'John': []}
self.asser... | [{"method_name": "add_user", "method_description": "def add_user(self, username):\n \"\"\"\n Add a new user to the Chat.\n :param username: The user's name, str.\n :return: If the user is already in the Chat, returns False, otherwise, returns True.\n >>> chat = Chat()\n >>> cha... | 4 | 4 | sequential | [
"datetime.now"
] | Chat | 3 | Implement the complete class. Return the complete Python file. | """This is a chat class with the functions of adding users, removing users, sending messages, and obtaining messages.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `add_user(self, username)`: Add a new user to the Chat.
- `remove_user(self, username)`: Remove a user from the C... |
def __init__(self):
self.users = {}
def add_user(self, username):
if username in self.users:
return False
else:
self.users[username] = []
return True
def remove_user(self, username):
if username in self.users:
del self.users[... | true | |
ClassEval_21 | FudanSELab/ClassEval | ClassEval_21 | from datetime import datetime
class Classroom:
def __init__(self, id):
self.id = id
self.courses = []
def add_course(self, course):
if course not in self.courses:
self.courses.append(course)
def remove_course(self, course):
if course in self.courses:
... | import unittest
from datetime import datetime
class ClassroomTestAddCourse(unittest.TestCase):
def test_add_course_1(self):
classroom = Classroom(1)
course = {'name': 'math', 'start_time': '09:00', 'end_time': '10:00'}
classroom.add_course(course)
self.assertIn(course, classroom.co... | [{"method_name": "add_course", "method_description": "def add_course(self, course):\n \"\"\"\n Add course to self.courses list if the course wasn't in it.\n :param course: dict, information of the course, including 'start_time', 'end_time' and 'name'\n >>> classroom = Classroom(1)\n >... | 4 | 4 | sequential | [] | Classroom | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class representing a classroom, capable of adding and removing courses, checking availability at a given time, and detecting conflicts when scheduling new courses."""
from datetime import datetime
class Classroom:
"""
This is a class representing a classroom, capable of adding and removing courses... | true | ||
ClassEval_21 | FudanSELab/ClassEval | ClassEval_21 | from datetime import datetime
class Classroom:
def __init__(self, id):
self.id = id
self.courses = []
def add_course(self, course):
if course not in self.courses:
self.courses.append(course)
def remove_course(self, course):
if course in self.courses:
... | import unittest
from datetime import datetime
class ClassroomTestAddCourse(unittest.TestCase):
def test_add_course_1(self):
classroom = Classroom(1)
course = {'name': 'math', 'start_time': '09:00', 'end_time': '10:00'}
classroom.add_course(course)
self.assertIn(course, classroom.co... | [{"method_name": "add_course", "method_description": "def add_course(self, course):\n \"\"\"\n Add course to self.courses list if the course wasn't in it.\n :param course: dict, information of the course, including 'start_time', 'end_time' and 'name'\n >>> classroom = Classroom(1)\n >... | 4 | 4 | sequential | [] | Classroom | 2 | Complete all missing function or method bodies. Return the complete Python file. | from datetime import datetime
class Classroom:
def __init__(self, id):
self.id = id
self.courses = []
def add_course(self, course):
if course not in self.courses:
self.courses.append(course)
def remove_course(self, course):
if course in self.courses:
... | true | ||
ClassEval_21 | FudanSELab/ClassEval | ClassEval_21 | from datetime import datetime
class Classroom:
def __init__(self, id):
self.id = id
self.courses = []
def add_course(self, course):
if course not in self.courses:
self.courses.append(course)
def remove_course(self, course):
if course in self.courses:
... | import unittest
from datetime import datetime
class ClassroomTestAddCourse(unittest.TestCase):
def test_add_course_1(self):
classroom = Classroom(1)
course = {'name': 'math', 'start_time': '09:00', 'end_time': '10:00'}
classroom.add_course(course)
self.assertIn(course, classroom.co... | [{"method_name": "add_course", "method_description": "def add_course(self, course):\n \"\"\"\n Add course to self.courses list if the course wasn't in it.\n :param course: dict, information of the course, including 'start_time', 'end_time' and 'name'\n >>> classroom = Classroom(1)\n >... | 4 | 4 | sequential | [] | Classroom | 3 | Implement the complete class. Return the complete Python file. | """This is a class representing a classroom, capable of adding and removing courses, checking availability at a given time, and detecting conflicts when scheduling new courses.
Required methods (implement on the class; order is not specified):
- `__init__(self, id)`
- `add_course(self, course)`: Add course to self.cou... |
def __init__(self, id):
self.id = id
self.courses = []
def add_course(self, course):
if course not in self.courses:
self.courses.append(course)
def remove_course(self, course):
if course in self.courses:
self.courses.remove(course)
def is_free_... | true | |
ClassEval_22 | FudanSELab/ClassEval | ClassEval_22 | class ClassRegistrationSystem:
def __init__(self):
self.students = []
self.students_registration_classes = {}
def register_student(self, student):
if student in self.students:
return 0
else:
self.students.append(student)
return 1
def reg... | import unittest
class ClassRegistrationSystemTestRegisterStudent(unittest.TestCase):
def setUp(self):
self.registration_system = ClassRegistrationSystem()
def test_register_student(self):
student1 = {"name": "John", "major": "Computer Science"}
self.assertEqual(self.registration_syst... | [{"method_name": "register_student", "method_description": "def register_student(self, student):\n \"\"\"\n register a student to the system, add the student to the students list, if the student is already registered, return 0, else return 1\n \"\"\"", "test_class": "ClassRegistrationSystemTestRegi... | 5 | 7 | sequential | [] | ClassRegistrationSystem | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class as a class registration system, allowing to register students, register them for classes, retrieve students by major, get a list of all majors, and determine the most popular class within a specific major."""
class ClassRegistrationSystem:
def __init__(self):
...
def register_stude... | true | ||
ClassEval_22 | FudanSELab/ClassEval | ClassEval_22 | class ClassRegistrationSystem:
def __init__(self):
self.students = []
self.students_registration_classes = {}
def register_student(self, student):
if student in self.students:
return 0
else:
self.students.append(student)
return 1
def reg... | import unittest
class ClassRegistrationSystemTestRegisterStudent(unittest.TestCase):
def setUp(self):
self.registration_system = ClassRegistrationSystem()
def test_register_student(self):
student1 = {"name": "John", "major": "Computer Science"}
self.assertEqual(self.registration_syst... | [{"method_name": "register_student", "method_description": "def register_student(self, student):\n \"\"\"\n register a student to the system, add the student to the students list, if the student is already registered, return 0, else return 1\n \"\"\"", "test_class": "ClassRegistrationSystemTestRegi... | 5 | 7 | sequential | [] | ClassRegistrationSystem | 2 | Complete all missing function or method bodies. Return the complete Python file. | class ClassRegistrationSystem:
def __init__(self):
self.students = []
self.students_registration_classes = {}
def register_student(self, student):
if student in self.students:
return 0
else:
self.students.append(student)
return 1
def reg... | true | ||
ClassEval_22 | FudanSELab/ClassEval | ClassEval_22 | class ClassRegistrationSystem:
def __init__(self):
self.students = []
self.students_registration_classes = {}
def register_student(self, student):
if student in self.students:
return 0
else:
self.students.append(student)
return 1
def reg... | import unittest
class ClassRegistrationSystemTestRegisterStudent(unittest.TestCase):
def setUp(self):
self.registration_system = ClassRegistrationSystem()
def test_register_student(self):
student1 = {"name": "John", "major": "Computer Science"}
self.assertEqual(self.registration_syst... | [{"method_name": "register_student", "method_description": "def register_student(self, student):\n \"\"\"\n register a student to the system, add the student to the students list, if the student is already registered, return 0, else return 1\n \"\"\"", "test_class": "ClassRegistrationSystemTestRegi... | 5 | 7 | sequential | [] | ClassRegistrationSystem | 3 | Implement the complete class. Return the complete Python file. | """This is a class as a class registration system, allowing to register students, register them for classes, retrieve students by major, get a list of all majors, and determine the most popular class within a specific major.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `regis... |
def __init__(self):
self.students = []
self.students_registration_classes = {}
def register_student(self, student):
if student in self.students:
return 0
else:
self.students.append(student)
return 1
def register_class(self, student_name,... | true | |
ClassEval_23 | FudanSELab/ClassEval | ClassEval_23 | import math
from typing import List
class CombinationCalculator:
def __init__(self, datas: List[str]):
self.datas = datas
@staticmethod
def count(n: int, m: int) -> int:
if m == 0 or n == m:
return 1
return math.factorial(n) // (math.factorial(n - m) * math.factorial(m)... | import unittest
class CombinationCalculatorTestCount(unittest.TestCase):
def test_count(self):
self.assertEqual(CombinationCalculator.count(4, 2), 6)
def test_count_2(self):
self.assertEqual(CombinationCalculator.count(5, 3), 10)
def test_count_3(self):
self.assertEqual(Combination... | [{"method_name": "count", "method_description": "def count(n: int, m: int) -> int:\n \"\"\"\n Calculate the number of combinations for a specific count.\n :param n: The total number of elements,int.\n :param m: The number of elements in each combination,int.\n :return: The number of c... | 5 | 5 | mixed | [] | CombinationCalculator | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class that provides methods to calculate the number of combinations for a specific count, calculate all possible combinations, and generate combinations with a specified number of elements."""
import math
from typing import List
class CombinationCalculator:
"""
This is a class that provides method... | true | ||
ClassEval_23 | FudanSELab/ClassEval | ClassEval_23 | import math
from typing import List
class CombinationCalculator:
def __init__(self, datas: List[str]):
self.datas = datas
@staticmethod
def count(n: int, m: int) -> int:
if m == 0 or n == m:
return 1
return math.factorial(n) // (math.factorial(n - m) * math.factorial(m)... | import unittest
class CombinationCalculatorTestCount(unittest.TestCase):
def test_count(self):
self.assertEqual(CombinationCalculator.count(4, 2), 6)
def test_count_2(self):
self.assertEqual(CombinationCalculator.count(5, 3), 10)
def test_count_3(self):
self.assertEqual(Combination... | [{"method_name": "count", "method_description": "def count(n: int, m: int) -> int:\n \"\"\"\n Calculate the number of combinations for a specific count.\n :param n: The total number of elements,int.\n :param m: The number of elements in each combination,int.\n :return: The number of c... | 5 | 5 | mixed | [] | CombinationCalculator | 2 | Complete all missing function or method bodies. Return the complete Python file. | import math
from typing import List
class CombinationCalculator:
def __init__(self, datas: List[str]):
self.datas = datas
@staticmethod
def count(n: int, m: int) -> int:
if m == 0 or n == m:
return 1
...
@staticmethod
def count_all(n: int) -> int:
if n... | true | ||
ClassEval_23 | FudanSELab/ClassEval | ClassEval_23 | import math
from typing import List
class CombinationCalculator:
def __init__(self, datas: List[str]):
self.datas = datas
@staticmethod
def count(n: int, m: int) -> int:
if m == 0 or n == m:
return 1
return math.factorial(n) // (math.factorial(n - m) * math.factorial(m)... | import unittest
class CombinationCalculatorTestCount(unittest.TestCase):
def test_count(self):
self.assertEqual(CombinationCalculator.count(4, 2), 6)
def test_count_2(self):
self.assertEqual(CombinationCalculator.count(5, 3), 10)
def test_count_3(self):
self.assertEqual(Combination... | [{"method_name": "count", "method_description": "def count(n: int, m: int) -> int:\n \"\"\"\n Calculate the number of combinations for a specific count.\n :param n: The total number of elements,int.\n :param m: The number of elements in each combination,int.\n :return: The number of c... | 5 | 5 | mixed | [] | CombinationCalculator | 3 | Implement the complete class. Return the complete Python file. | """This is a class that provides methods to calculate the number of combinations for a specific count, calculate all possible combinations, and generate combinations with a specified number of elements.
Required methods (implement on the class; order is not specified):
- `__init__(self, datas: List[str])`
- `count(n: ... |
def __init__(self, datas: List[str]):
self.datas = datas
@staticmethod
def count(n: int, m: int) -> int:
if m == 0 or n == m:
return 1
return math.factorial(n) // (math.factorial(n - m) * math.factorial(m))
@staticmethod
def count_all(n: int) -> int:
if... | true | |
ClassEval_24 | FudanSELab/ClassEval | ClassEval_24 | class ComplexCalculator:
def __init__(self):
pass
@staticmethod
def add(c1, c2):
real = c1.real + c2.real
imaginary = c1.imag + c2.imag
answer = complex(real, imaginary)
return answer
@staticmethod
def subtract(c1, c2):
real = c1.real - c2.real
... | import unittest
class ComplexCalculatorTestAdd(unittest.TestCase):
def test_add(self):
complexCalculator = ComplexCalculator()
self.assertEqual(complexCalculator.add(1+2j, 3+4j), (4+6j))
def test_add_2(self):
complexCalculator = ComplexCalculator()
self.assertEqual(complexCalcu... | [{"method_name": "add", "method_description": "def add(c1, c2):\n \"\"\"\n Adds two complex numbers.\n :param c1: The first complex number,complex.\n :param c2: The second complex number,complex.\n :return: The sum of the two complex numbers,complex.\n >>> complexCalculator = C... | 4 | 0 | parallel | [] | ComplexCalculator | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class that implements addition, subtraction, multiplication, and division operations for complex numbers."""
class ComplexCalculator:
"""
This is a class that implements addition, subtraction, multiplication, and division operations for complex numbers.
"""
def __init__(self):
...... | true | ||
ClassEval_24 | FudanSELab/ClassEval | ClassEval_24 | class ComplexCalculator:
def __init__(self):
pass
@staticmethod
def add(c1, c2):
real = c1.real + c2.real
imaginary = c1.imag + c2.imag
answer = complex(real, imaginary)
return answer
@staticmethod
def subtract(c1, c2):
real = c1.real - c2.real
... | import unittest
class ComplexCalculatorTestAdd(unittest.TestCase):
def test_add(self):
complexCalculator = ComplexCalculator()
self.assertEqual(complexCalculator.add(1+2j, 3+4j), (4+6j))
def test_add_2(self):
complexCalculator = ComplexCalculator()
self.assertEqual(complexCalcu... | [{"method_name": "add", "method_description": "def add(c1, c2):\n \"\"\"\n Adds two complex numbers.\n :param c1: The first complex number,complex.\n :param c2: The second complex number,complex.\n :return: The sum of the two complex numbers,complex.\n >>> complexCalculator = C... | 4 | 0 | parallel | [] | ComplexCalculator | 2 | Complete all missing function or method bodies. Return the complete Python file. | class ComplexCalculator:
def __init__(self):
pass
@staticmethod
def add(c1, c2):
real = c1.real + c2.real
...
@staticmethod
def subtract(c1, c2):
real = c1.real - c2.real
...
@staticmethod
def multiply(c1, c2):
real = c1.real * c2.real - c1... | true | ||
ClassEval_24 | FudanSELab/ClassEval | ClassEval_24 | class ComplexCalculator:
def __init__(self):
pass
@staticmethod
def add(c1, c2):
real = c1.real + c2.real
imaginary = c1.imag + c2.imag
answer = complex(real, imaginary)
return answer
@staticmethod
def subtract(c1, c2):
real = c1.real - c2.real
... | import unittest
class ComplexCalculatorTestAdd(unittest.TestCase):
def test_add(self):
complexCalculator = ComplexCalculator()
self.assertEqual(complexCalculator.add(1+2j, 3+4j), (4+6j))
def test_add_2(self):
complexCalculator = ComplexCalculator()
self.assertEqual(complexCalcu... | [{"method_name": "add", "method_description": "def add(c1, c2):\n \"\"\"\n Adds two complex numbers.\n :param c1: The first complex number,complex.\n :param c2: The second complex number,complex.\n :return: The sum of the two complex numbers,complex.\n >>> complexCalculator = C... | 4 | 0 | parallel | [] | ComplexCalculator | 3 | Implement the complete class. Return the complete Python file. | """This is a class that implements addition, subtraction, multiplication, and division operations for complex numbers.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `add(c1, c2)`: Adds two complex numbers.
- `subtract(...)`: Subtracts two complex numbers.
- `multiply(...)`: Mu... |
def __init__(self):
pass
@staticmethod
def add(c1, c2):
real = c1.real + c2.real
imaginary = c1.imag + c2.imag
answer = complex(real, imaginary)
return answer
@staticmethod
def subtract(c1, c2):
real = c1.real - c2.real
imaginary = c1.imag -... | true | |
ClassEval_25 | FudanSELab/ClassEval | ClassEval_25 | import json
class CookiesUtil:
def __init__(self, cookies_file):
self.cookies_file = cookies_file
self.cookies = None
def get_cookies(self, reponse):
self.cookies = reponse['cookies']
self._save_cookies()
def load_cookies(self):
try:
with open(self.cook... | import unittest
class CookiesUtilTestGetCookies(unittest.TestCase):
def test_get_cookies(self):
self.cookies_util = CookiesUtil('cookies.json')
self.response = {'cookies': {'key1': 'value1', 'key2': 'value2'}}
self.cookies_util.get_cookies(self.response)
self.assertEqual(self.cook... | [{"method_name": "get_cookies", "method_description": "def get_cookies(self, reponse):\n \"\"\"\n Gets the cookies from the specified response,and save it to cookies_file.\n :param reponse: The response to get cookies from, dict.\n >>> cookies_util = CookiesUtil('cookies.json')\n >>> ... | 3 | 6 | sequential | [
"open("
] | CookiesUtil | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class as utility for managing and manipulating Cookies, including methods for retrieving, saving, and setting Cookies data."""
import json
class CookiesUtil:
"""
This is a class as utility for managing and manipulating Cookies, including methods for retrieving, saving, and setting Cookies data.
... | true | ||
ClassEval_25 | FudanSELab/ClassEval | ClassEval_25 | import json
class CookiesUtil:
def __init__(self, cookies_file):
self.cookies_file = cookies_file
self.cookies = None
def get_cookies(self, reponse):
self.cookies = reponse['cookies']
self._save_cookies()
def load_cookies(self):
try:
with open(self.cook... | import unittest
class CookiesUtilTestGetCookies(unittest.TestCase):
def test_get_cookies(self):
self.cookies_util = CookiesUtil('cookies.json')
self.response = {'cookies': {'key1': 'value1', 'key2': 'value2'}}
self.cookies_util.get_cookies(self.response)
self.assertEqual(self.cook... | [{"method_name": "get_cookies", "method_description": "def get_cookies(self, reponse):\n \"\"\"\n Gets the cookies from the specified response,and save it to cookies_file.\n :param reponse: The response to get cookies from, dict.\n >>> cookies_util = CookiesUtil('cookies.json')\n >>> ... | 3 | 6 | sequential | [
"open("
] | CookiesUtil | 2 | Complete all missing function or method bodies. Return the complete Python file. | import json
class CookiesUtil:
def __init__(self, cookies_file):
self.cookies_file = cookies_file
self.cookies = None
def get_cookies(self, reponse):
self.cookies = reponse['cookies']
...
def load_cookies(self):
try:
with open(self.cookies_file, 'r') a... | true | ||
ClassEval_25 | FudanSELab/ClassEval | ClassEval_25 | import json
class CookiesUtil:
def __init__(self, cookies_file):
self.cookies_file = cookies_file
self.cookies = None
def get_cookies(self, reponse):
self.cookies = reponse['cookies']
self._save_cookies()
def load_cookies(self):
try:
with open(self.cook... | import unittest
class CookiesUtilTestGetCookies(unittest.TestCase):
def test_get_cookies(self):
self.cookies_util = CookiesUtil('cookies.json')
self.response = {'cookies': {'key1': 'value1', 'key2': 'value2'}}
self.cookies_util.get_cookies(self.response)
self.assertEqual(self.cook... | [{"method_name": "get_cookies", "method_description": "def get_cookies(self, reponse):\n \"\"\"\n Gets the cookies from the specified response,and save it to cookies_file.\n :param reponse: The response to get cookies from, dict.\n >>> cookies_util = CookiesUtil('cookies.json')\n >>> ... | 3 | 6 | sequential | [
"open("
] | CookiesUtil | 3 | Implement the complete class. Return the complete Python file. | """This is a class as utility for managing and manipulating Cookies, including methods for retrieving, saving, and setting Cookies data.
Required methods (implement on the class; order is not specified):
- `__init__(self, cookies_file)`
- `get_cookies(self, reponse)`: Gets the cookies from the specified response,and s... |
def __init__(self, cookies_file):
self.cookies_file = cookies_file
self.cookies = None
def get_cookies(self, reponse):
self.cookies = reponse['cookies']
self._save_cookies()
def load_cookies(self):
try:
with open(self.cookies_file, 'r') as file:
... | true | |
ClassEval_26 | FudanSELab/ClassEval | ClassEval_26 | import csv
class CSVProcessor:
def __init__(self):
pass
def read_csv(self, file_name):
data = []
with open(file_name, 'r') as file:
reader = csv.reader(file)
title = next(reader)
for row in reader:
data.append(row)
return ti... | import unittest
import os
class CSVProcessorTestReadCSV(unittest.TestCase):
def test_read_csv_1(self):
self.file = 'read_test.csv'
with open(self.file, 'w') as f:
f.write('a,b,c,d\nhElLo,YoU,ME,LoW')
expected_title = ['a', 'b', 'c', 'd']
expected_data = [['hElLo', 'Yo... | [{"method_name": "read_csv", "method_description": "def read_csv(self, file_name):\n \"\"\"\n Read the csv file by file_name, get the title and data from it\n :param file_name: str, name of the csv file\n :return title, data: (list, list), first row is title, the rest is data\n >>> cs... | 3 | 2 | mixed | [
"open("
] | CSVProcessor | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class for processing CSV files, including readring and writing CSV data, as well as processing specific operations and saving as a new CSV file."""
import csv
class CSVProcessor:
"""
This is a class for processing CSV files, including readring and writing CSV data, as well as processing specific o... | true | ||
ClassEval_26 | FudanSELab/ClassEval | ClassEval_26 | import csv
class CSVProcessor:
def __init__(self):
pass
def read_csv(self, file_name):
data = []
with open(file_name, 'r') as file:
reader = csv.reader(file)
title = next(reader)
for row in reader:
data.append(row)
return ti... | import unittest
import os
class CSVProcessorTestReadCSV(unittest.TestCase):
def test_read_csv_1(self):
self.file = 'read_test.csv'
with open(self.file, 'w') as f:
f.write('a,b,c,d\nhElLo,YoU,ME,LoW')
expected_title = ['a', 'b', 'c', 'd']
expected_data = [['hElLo', 'Yo... | [{"method_name": "read_csv", "method_description": "def read_csv(self, file_name):\n \"\"\"\n Read the csv file by file_name, get the title and data from it\n :param file_name: str, name of the csv file\n :return title, data: (list, list), first row is title, the rest is data\n >>> cs... | 3 | 2 | mixed | [
"open("
] | CSVProcessor | 2 | Complete all missing function or method bodies. Return the complete Python file. | import csv
class CSVProcessor:
def __init__(self):
pass
def read_csv(self, file_name):
data = []
...
def write_csv(self, data, file_name):
try:
with open(file_name, 'w', newline='') as file:
writer = csv.writer(file)
writer.writ... | true | ||
ClassEval_26 | FudanSELab/ClassEval | ClassEval_26 | import csv
class CSVProcessor:
def __init__(self):
pass
def read_csv(self, file_name):
data = []
with open(file_name, 'r') as file:
reader = csv.reader(file)
title = next(reader)
for row in reader:
data.append(row)
return ti... | import unittest
import os
class CSVProcessorTestReadCSV(unittest.TestCase):
def test_read_csv_1(self):
self.file = 'read_test.csv'
with open(self.file, 'w') as f:
f.write('a,b,c,d\nhElLo,YoU,ME,LoW')
expected_title = ['a', 'b', 'c', 'd']
expected_data = [['hElLo', 'Yo... | [{"method_name": "read_csv", "method_description": "def read_csv(self, file_name):\n \"\"\"\n Read the csv file by file_name, get the title and data from it\n :param file_name: str, name of the csv file\n :return title, data: (list, list), first row is title, the rest is data\n >>> cs... | 3 | 2 | mixed | [
"open("
] | CSVProcessor | 3 | Implement the complete class. Return the complete Python file. | """This is a class for processing CSV files, including readring and writing CSV data, as well as processing specific operations and saving as a new CSV file.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `read_csv(self, file_name)`: Read the csv file by file_name, get the titl... |
def __init__(self):
pass
def read_csv(self, file_name):
data = []
with open(file_name, 'r') as file:
reader = csv.reader(file)
title = next(reader)
for row in reader:
data.append(row)
return (title, data)
def write_csv(se... | true | |
ClassEval_27 | FudanSELab/ClassEval | ClassEval_27 | class CurrencyConverter:
def __init__(self):
self.rates = {
'USD': 1.0,
'EUR': 0.85,
'GBP': 0.72,
'JPY': 110.15,
'CAD': 1.23,
'AUD': 1.34,
'CNY': 6.40,
}
def convert(self, amount, from_currency, to_currency):
... | import unittest
class CurrencyConverterTestConvert(unittest.TestCase):
def test_convert_1(self):
cc = CurrencyConverter()
res = cc.convert(64, 'CNY', 'USD')
self.assertEqual(res, 10.0)
def test_convert_2(self):
cc = CurrencyConverter()
res = cc.convert(64, 'USD', 'USD'... | [{"method_name": "convert", "method_description": "def convert(self, amount, from_currency, to_currency):\n \"\"\"\n Convert the value of a given currency to another currency type\n :param amount: float, The value of a given currency\n :param from_currency: string, source currency type\n ... | 4 | 4 | sequential | [] | CurrencyConverter | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class for currency conversion, which supports to convert amounts between different currencies, retrieve supported currencies, add new currency rates, and update existing currency rates."""
class CurrencyConverter:
"""
This is a class for currency conversion, which supports to convert amounts betwe... | true | ||
ClassEval_27 | FudanSELab/ClassEval | ClassEval_27 | class CurrencyConverter:
def __init__(self):
self.rates = {
'USD': 1.0,
'EUR': 0.85,
'GBP': 0.72,
'JPY': 110.15,
'CAD': 1.23,
'AUD': 1.34,
'CNY': 6.40,
}
def convert(self, amount, from_currency, to_currency):
... | import unittest
class CurrencyConverterTestConvert(unittest.TestCase):
def test_convert_1(self):
cc = CurrencyConverter()
res = cc.convert(64, 'CNY', 'USD')
self.assertEqual(res, 10.0)
def test_convert_2(self):
cc = CurrencyConverter()
res = cc.convert(64, 'USD', 'USD'... | [{"method_name": "convert", "method_description": "def convert(self, amount, from_currency, to_currency):\n \"\"\"\n Convert the value of a given currency to another currency type\n :param amount: float, The value of a given currency\n :param from_currency: string, source currency type\n ... | 4 | 4 | sequential | [] | CurrencyConverter | 2 | Complete all missing function or method bodies. Return the complete Python file. | class CurrencyConverter:
def __init__(self):
self.rates = {'USD': 1.0, 'EUR': 0.85, 'GBP': 0.72, 'JPY': 110.15, 'CAD': 1.23, 'AUD': 1.34, 'CNY': 6.4}
def convert(self, amount, from_currency, to_currency):
if from_currency == to_currency:
return amount
if from_currency not i... | true | ||
ClassEval_27 | FudanSELab/ClassEval | ClassEval_27 | class CurrencyConverter:
def __init__(self):
self.rates = {
'USD': 1.0,
'EUR': 0.85,
'GBP': 0.72,
'JPY': 110.15,
'CAD': 1.23,
'AUD': 1.34,
'CNY': 6.40,
}
def convert(self, amount, from_currency, to_currency):
... | import unittest
class CurrencyConverterTestConvert(unittest.TestCase):
def test_convert_1(self):
cc = CurrencyConverter()
res = cc.convert(64, 'CNY', 'USD')
self.assertEqual(res, 10.0)
def test_convert_2(self):
cc = CurrencyConverter()
res = cc.convert(64, 'USD', 'USD'... | [{"method_name": "convert", "method_description": "def convert(self, amount, from_currency, to_currency):\n \"\"\"\n Convert the value of a given currency to another currency type\n :param amount: float, The value of a given currency\n :param from_currency: string, source currency type\n ... | 4 | 4 | sequential | [] | CurrencyConverter | 3 | Implement the complete class. Return the complete Python file. | """This is a class for currency conversion, which supports to convert amounts between different currencies, retrieve supported currencies, add new currency rates, and update existing currency rates.
Required methods (implement on the class; order is not specified):
- `__init__(self)`
- `convert(self, amount, from_curr... |
def __init__(self):
self.rates = {'USD': 1.0, 'EUR': 0.85, 'GBP': 0.72, 'JPY': 110.15, 'CAD': 1.23, 'AUD': 1.34, 'CNY': 6.4}
def convert(self, amount, from_currency, to_currency):
if from_currency == to_currency:
return amount
if from_currency not in self.rates or to_curren... | true | |
ClassEval_28 | FudanSELab/ClassEval | ClassEval_28 | import sqlite3
import pandas as pd
class DatabaseProcessor:
def __init__(self, database_name):
self.database_name = database_name
def create_table(self, table_name, key1, key2):
conn = sqlite3.connect(self.database_name)
cursor = conn.cursor()
create_table_query = f"CREATE T... | import unittest
import sqlite3
class DatabaseProcessorTestCreateTable(unittest.TestCase):
def setUp(self):
self.database_name = "test.db"
self.processor = DatabaseProcessor(self.database_name)
def tearDown(self):
conn = sqlite3.connect(self.database_name)
cursor = conn.cursor(... | [{"method_name": "create_table", "method_description": "def create_table(self, table_name, key1, key2):\n \"\"\"\n Create a new table in the database if it doesn't exist.\n And make id (INTEGER) as PRIMARY KEY, make key1 as TEXT, key2 as INTEGER\n :param table_name: str, the name of the tabl... | 4 | 4 | sequential | [] | DatabaseProcessor | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class for processing a database, supporting to create tables, insert data into the database, search for data based on name, and delete data from the database."""
import sqlite3
import pandas as pd
class DatabaseProcessor:
"""
This is a class for processing a database, supporting to create tables, ... | true | ||
ClassEval_28 | FudanSELab/ClassEval | ClassEval_28 | import sqlite3
import pandas as pd
class DatabaseProcessor:
def __init__(self, database_name):
self.database_name = database_name
def create_table(self, table_name, key1, key2):
conn = sqlite3.connect(self.database_name)
cursor = conn.cursor()
create_table_query = f"CREATE T... | import unittest
import sqlite3
class DatabaseProcessorTestCreateTable(unittest.TestCase):
def setUp(self):
self.database_name = "test.db"
self.processor = DatabaseProcessor(self.database_name)
def tearDown(self):
conn = sqlite3.connect(self.database_name)
cursor = conn.cursor(... | [{"method_name": "create_table", "method_description": "def create_table(self, table_name, key1, key2):\n \"\"\"\n Create a new table in the database if it doesn't exist.\n And make id (INTEGER) as PRIMARY KEY, make key1 as TEXT, key2 as INTEGER\n :param table_name: str, the name of the tabl... | 4 | 4 | sequential | [] | DatabaseProcessor | 2 | Complete all missing function or method bodies. Return the complete Python file. | import sqlite3
import pandas as pd
class DatabaseProcessor:
def __init__(self, database_name):
self.database_name = database_name
def create_table(self, table_name, key1, key2):
conn = sqlite3.connect(self.database_name)
cursor = conn.cursor()
...
def insert_into_database... | true | ||
ClassEval_28 | FudanSELab/ClassEval | ClassEval_28 | import sqlite3
import pandas as pd
class DatabaseProcessor:
def __init__(self, database_name):
self.database_name = database_name
def create_table(self, table_name, key1, key2):
conn = sqlite3.connect(self.database_name)
cursor = conn.cursor()
create_table_query = f"CREATE T... | import unittest
import sqlite3
class DatabaseProcessorTestCreateTable(unittest.TestCase):
def setUp(self):
self.database_name = "test.db"
self.processor = DatabaseProcessor(self.database_name)
def tearDown(self):
conn = sqlite3.connect(self.database_name)
cursor = conn.cursor(... | [{"method_name": "create_table", "method_description": "def create_table(self, table_name, key1, key2):\n \"\"\"\n Create a new table in the database if it doesn't exist.\n And make id (INTEGER) as PRIMARY KEY, make key1 as TEXT, key2 as INTEGER\n :param table_name: str, the name of the tabl... | 4 | 4 | sequential | [] | DatabaseProcessor | 3 | Implement the complete class. Return the complete Python file. | """This is a class for processing a database, supporting to create tables, insert data into the database, search for data based on name, and delete data from the database.
Required methods (implement on the class; order is not specified):
- `__init__(self, database_name)`
- `create_table(self, table_name, key1, key2)`... |
def __init__(self, database_name):
self.database_name = database_name
def create_table(self, table_name, key1, key2):
conn = sqlite3.connect(self.database_name)
cursor = conn.cursor()
create_table_query = f'CREATE TABLE IF NOT EXISTS {table_name} (id INTEGER PRIMARY KEY, {key1}... | true | |
ClassEval_29 | FudanSELab/ClassEval | ClassEval_29 | from collections import Counter
class DataStatistics:
def mean(self, data):
return round(sum(data) / len(data), 2)
def median(self, data):
sorted_data = sorted(data)
n = len(sorted_data)
if n % 2 == 0:
middle = n // 2
return round((sorted_data[middle - ... | import unittest
class DataStatisticsTestMean(unittest.TestCase):
def test_mean_1(self):
ds = DataStatistics()
res = ds.mean([1, 2, 3, 4, 5])
self.assertEqual(res, 3.00)
def test_mean_2(self):
ds = DataStatistics()
res = ds.mean([1, 2, 3, 4, 5, 6])
self.assertEq... | [{"method_name": "mean", "method_description": "def mean(self, data):\n \"\"\"\n Calculate the average value of a group of data, accurate to two digits after the Decimal separator\n :param data:list, data list\n :return:float, the mean value\n >>> ds = DataStatistics()\n >>> ds... | 3 | 0 | parallel | [] | DataStatistics | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class for performing data statistics, supporting to calculate the mean, median, and mode of a given data set."""
from collections import Counter
class DataStatistics:
"""
This is a class for performing data statistics, supporting to calculate the mean, median, and mode of a given data set.
"""... | true | ||
ClassEval_29 | FudanSELab/ClassEval | ClassEval_29 | from collections import Counter
class DataStatistics:
def mean(self, data):
return round(sum(data) / len(data), 2)
def median(self, data):
sorted_data = sorted(data)
n = len(sorted_data)
if n % 2 == 0:
middle = n // 2
return round((sorted_data[middle - ... | import unittest
class DataStatisticsTestMean(unittest.TestCase):
def test_mean_1(self):
ds = DataStatistics()
res = ds.mean([1, 2, 3, 4, 5])
self.assertEqual(res, 3.00)
def test_mean_2(self):
ds = DataStatistics()
res = ds.mean([1, 2, 3, 4, 5, 6])
self.assertEq... | [{"method_name": "mean", "method_description": "def mean(self, data):\n \"\"\"\n Calculate the average value of a group of data, accurate to two digits after the Decimal separator\n :param data:list, data list\n :return:float, the mean value\n >>> ds = DataStatistics()\n >>> ds... | 3 | 0 | parallel | [] | DataStatistics | 2 | Complete all missing function or method bodies. Return the complete Python file. | from collections import Counter
class DataStatistics:
def mean(self, data):
return round(sum(data) / len(data), 2)
def median(self, data):
sorted_data = sorted(data)
...
def mode(self, data):
counter = Counter(data)
...
| true | ||
ClassEval_29 | FudanSELab/ClassEval | ClassEval_29 | from collections import Counter
class DataStatistics:
def mean(self, data):
return round(sum(data) / len(data), 2)
def median(self, data):
sorted_data = sorted(data)
n = len(sorted_data)
if n % 2 == 0:
middle = n // 2
return round((sorted_data[middle - ... | import unittest
class DataStatisticsTestMean(unittest.TestCase):
def test_mean_1(self):
ds = DataStatistics()
res = ds.mean([1, 2, 3, 4, 5])
self.assertEqual(res, 3.00)
def test_mean_2(self):
ds = DataStatistics()
res = ds.mean([1, 2, 3, 4, 5, 6])
self.assertEq... | [{"method_name": "mean", "method_description": "def mean(self, data):\n \"\"\"\n Calculate the average value of a group of data, accurate to two digits after the Decimal separator\n :param data:list, data list\n :return:float, the mean value\n >>> ds = DataStatistics()\n >>> ds... | 3 | 0 | parallel | [] | DataStatistics | 3 | Implement the complete class. Return the complete Python file. | """This is a class for performing data statistics, supporting to calculate the mean, median, and mode of a given data set.
Required methods (implement on the class; order is not specified):
- `mean(self, data)`: Calculate the average value of a group of data, accurate to two digits after the Decimal separator
- `media... |
def mean(self, data):
return round(sum(data) / len(data), 2)
def median(self, data):
sorted_data = sorted(data)
n = len(sorted_data)
if n % 2 == 0:
middle = n // 2
return round((sorted_data[middle - 1] + sorted_data[middle]) / 2, 2)
else:
... | true | |
ClassEval_30 | FudanSELab/ClassEval | ClassEval_30 | import numpy as np
class DataStatistics2:
def __init__(self, data):
self.data = np.array(data)
def get_sum(self):
return np.sum(self.data)
def get_min(self):
return np.min(self.data)
def get_max(self):
return np.max(self.data)
def get_variance(self):
ret... | import unittest
class DataStatistics2TestGetSum(unittest.TestCase):
def test_get_sum_1(self):
ds2 = DataStatistics2([1, 2, 3, 4])
res = ds2.get_sum()
self.assertEqual(res, 10)
def test_get_sum_2(self):
ds2 = DataStatistics2([1, 2, 203, 4])
res = ds2.get_sum()
s... | [{"method_name": "get_sum", "method_description": "def get_sum(self):\n \"\"\"\n Calculate the sum of data\n :return:float\n >>> ds2 = DataStatistics2([1, 2, 3, 4])\n >>> ds2.get_sum()\n 10\n \"\"\"", "test_class": "DataStatistics2TestGetSum", "test_code": "class DataSta... | 6 | 6 | sequential | [] | DataStatistics2 | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class for performing data statistics, supporting to get the sum, minimum, maximum, variance, standard deviation, and correlation of a given dataset."""
import numpy as np
class DataStatistics2:
"""
This is a class for performing data statistics, supporting to get the sum, minimum, maximum, varianc... | true | ||
ClassEval_30 | FudanSELab/ClassEval | ClassEval_30 | import numpy as np
class DataStatistics2:
def __init__(self, data):
self.data = np.array(data)
def get_sum(self):
return np.sum(self.data)
def get_min(self):
return np.min(self.data)
def get_max(self):
return np.max(self.data)
def get_variance(self):
ret... | import unittest
class DataStatistics2TestGetSum(unittest.TestCase):
def test_get_sum_1(self):
ds2 = DataStatistics2([1, 2, 3, 4])
res = ds2.get_sum()
self.assertEqual(res, 10)
def test_get_sum_2(self):
ds2 = DataStatistics2([1, 2, 203, 4])
res = ds2.get_sum()
s... | [{"method_name": "get_sum", "method_description": "def get_sum(self):\n \"\"\"\n Calculate the sum of data\n :return:float\n >>> ds2 = DataStatistics2([1, 2, 3, 4])\n >>> ds2.get_sum()\n 10\n \"\"\"", "test_class": "DataStatistics2TestGetSum", "test_code": "class DataSta... | 6 | 6 | sequential | [] | DataStatistics2 | 2 | Complete all missing function or method bodies. Return the complete Python file. | import numpy as np
class DataStatistics2:
def __init__(self, data):
self.data = np.array(data)
def get_sum(self):
return np.sum(self.data)
def get_min(self):
return np.min(self.data)
def get_max(self):
return np.max(self.data)
def get_variance(self):
ret... | true | ||
ClassEval_30 | FudanSELab/ClassEval | ClassEval_30 | import numpy as np
class DataStatistics2:
def __init__(self, data):
self.data = np.array(data)
def get_sum(self):
return np.sum(self.data)
def get_min(self):
return np.min(self.data)
def get_max(self):
return np.max(self.data)
def get_variance(self):
ret... | import unittest
class DataStatistics2TestGetSum(unittest.TestCase):
def test_get_sum_1(self):
ds2 = DataStatistics2([1, 2, 3, 4])
res = ds2.get_sum()
self.assertEqual(res, 10)
def test_get_sum_2(self):
ds2 = DataStatistics2([1, 2, 203, 4])
res = ds2.get_sum()
s... | [{"method_name": "get_sum", "method_description": "def get_sum(self):\n \"\"\"\n Calculate the sum of data\n :return:float\n >>> ds2 = DataStatistics2([1, 2, 3, 4])\n >>> ds2.get_sum()\n 10\n \"\"\"", "test_class": "DataStatistics2TestGetSum", "test_code": "class DataSta... | 6 | 6 | sequential | [] | DataStatistics2 | 3 | Implement the complete class. Return the complete Python file. | """This is a class for performing data statistics, supporting to get the sum, minimum, maximum, variance, standard deviation, and correlation of a given dataset.
Required methods (implement on the class; order is not specified):
- `__init__(self, data)`
- `get_sum(self)`: Calculate the sum of data
- `get_min(self)`: C... |
def __init__(self, data):
self.data = np.array(data)
def get_sum(self):
return np.sum(self.data)
def get_min(self):
return np.min(self.data)
def get_max(self):
return np.max(self.data)
def get_variance(self):
return round(np.var(self.data), 2)
def ge... | true | |
ClassEval_31 | FudanSELab/ClassEval | ClassEval_31 | import math
class DataStatistics4:
@staticmethod
def correlation_coefficient(data1, data2):
n = len(data1)
mean1 = sum(data1) / n
mean2 = sum(data2) / n
numerator = sum((data1[i] - mean1) * (data2[i] - mean2) for i in range(n))
denominator = math.sqrt(sum((data1[i] - m... | import unittest
class DataStatistics4TestCorrelationCoefficient(unittest.TestCase):
def test_correlation_coefficient(self):
self.assertEqual(DataStatistics4.correlation_coefficient([1, 2, 3], [4, 5, 6]), 0.9999999999999998)
def test_correlation_coefficient_2(self):
self.assertEqual(DataStatis... | [{"method_name": "correlation_coefficient", "method_description": "def correlation_coefficient(data1, data2):\n \"\"\"\n Calculate the correlation coefficient of two sets of data.\n :param data1: The first set of data,list.\n :param data2: The second set of data,list.\n :return: The c... | 4 | 0 | parallel | [] | DataStatistics4 | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class that performs advanced mathematical calculations and statistics, including correlation coefficient, skewness, kurtosis, and probability density function (PDF) for a normal distribution."""
import math
class DataStatistics4:
"""
This is a class that performs advanced mathematical calculations... | true | ||
ClassEval_31 | FudanSELab/ClassEval | ClassEval_31 | import math
class DataStatistics4:
@staticmethod
def correlation_coefficient(data1, data2):
n = len(data1)
mean1 = sum(data1) / n
mean2 = sum(data2) / n
numerator = sum((data1[i] - mean1) * (data2[i] - mean2) for i in range(n))
denominator = math.sqrt(sum((data1[i] - m... | import unittest
class DataStatistics4TestCorrelationCoefficient(unittest.TestCase):
def test_correlation_coefficient(self):
self.assertEqual(DataStatistics4.correlation_coefficient([1, 2, 3], [4, 5, 6]), 0.9999999999999998)
def test_correlation_coefficient_2(self):
self.assertEqual(DataStatis... | [{"method_name": "correlation_coefficient", "method_description": "def correlation_coefficient(data1, data2):\n \"\"\"\n Calculate the correlation coefficient of two sets of data.\n :param data1: The first set of data,list.\n :param data2: The second set of data,list.\n :return: The c... | 4 | 0 | parallel | [] | DataStatistics4 | 2 | Complete all missing function or method bodies. Return the complete Python file. | import math
class DataStatistics4:
@staticmethod
def correlation_coefficient(data1, data2):
n = len(data1)
mean1 = sum(data1) / n
...
@staticmethod
def skewness(data):
n = len(data)
mean = sum(data) / n
...
@staticmethod
def kurtosis(data):
... | true | ||
ClassEval_31 | FudanSELab/ClassEval | ClassEval_31 | import math
class DataStatistics4:
@staticmethod
def correlation_coefficient(data1, data2):
n = len(data1)
mean1 = sum(data1) / n
mean2 = sum(data2) / n
numerator = sum((data1[i] - mean1) * (data2[i] - mean2) for i in range(n))
denominator = math.sqrt(sum((data1[i] - m... | import unittest
class DataStatistics4TestCorrelationCoefficient(unittest.TestCase):
def test_correlation_coefficient(self):
self.assertEqual(DataStatistics4.correlation_coefficient([1, 2, 3], [4, 5, 6]), 0.9999999999999998)
def test_correlation_coefficient_2(self):
self.assertEqual(DataStatis... | [{"method_name": "correlation_coefficient", "method_description": "def correlation_coefficient(data1, data2):\n \"\"\"\n Calculate the correlation coefficient of two sets of data.\n :param data1: The first set of data,list.\n :param data2: The second set of data,list.\n :return: The c... | 4 | 0 | parallel | [] | DataStatistics4 | 3 | Implement the complete class. Return the complete Python file. | """This is a class that performs advanced mathematical calculations and statistics, including correlation coefficient, skewness, kurtosis, and probability density function (PDF) for a normal distribution.
Required methods (implement on the class; order is not specified):
- `correlation_coefficient(data1, data2)`: Calc... |
@staticmethod
def correlation_coefficient(data1, data2):
n = len(data1)
mean1 = sum(data1) / n
mean2 = sum(data2) / n
numerator = sum(((data1[i] - mean1) * (data2[i] - mean2) for i in range(n)))
denominator = math.sqrt(sum(((data1[i] - mean1) ** 2 for i in range(n)))) * ... | true | |
ClassEval_32 | FudanSELab/ClassEval | ClassEval_32 | class DecryptionUtils:
def __init__(self, key):
self.key = key
def caesar_decipher(self, ciphertext, shift):
plaintext = ""
for char in ciphertext:
if char.isalpha():
if char.isupper():
ascii_offset = 65
else:
... | import unittest
class DecryptionUtilsTestCaesarDecipher(unittest.TestCase):
def test_caesar_decipher(self):
d = DecryptionUtils('key')
self.assertEqual(d.caesar_decipher('ifmmp', 1), 'hello')
def test_caesar_decipher_2(self):
d = DecryptionUtils('key')
self.assertEqual(d.caesa... | [{"method_name": "caesar_decipher", "method_description": "def caesar_decipher(self, ciphertext, shift):\n \"\"\"\n Deciphers the given ciphertext using the Caesar cipher\n :param ciphertext: The ciphertext to decipher,str.\n :param shift: The shift to use for decryption,int.\n :retur... | 3 | 1 | mixed | [] | DecryptionUtils | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class that provides methods for decryption, including the Caesar cipher, Vigenere cipher, and Rail Fence cipher."""
class DecryptionUtils:
"""
This is a class that provides methods for decryption, including the Caesar cipher, Vigenere cipher, and Rail Fence cipher.
"""
def __init__(self, ... | true | ||
ClassEval_32 | FudanSELab/ClassEval | ClassEval_32 | class DecryptionUtils:
def __init__(self, key):
self.key = key
def caesar_decipher(self, ciphertext, shift):
plaintext = ""
for char in ciphertext:
if char.isalpha():
if char.isupper():
ascii_offset = 65
else:
... | import unittest
class DecryptionUtilsTestCaesarDecipher(unittest.TestCase):
def test_caesar_decipher(self):
d = DecryptionUtils('key')
self.assertEqual(d.caesar_decipher('ifmmp', 1), 'hello')
def test_caesar_decipher_2(self):
d = DecryptionUtils('key')
self.assertEqual(d.caesa... | [{"method_name": "caesar_decipher", "method_description": "def caesar_decipher(self, ciphertext, shift):\n \"\"\"\n Deciphers the given ciphertext using the Caesar cipher\n :param ciphertext: The ciphertext to decipher,str.\n :param shift: The shift to use for decryption,int.\n :retur... | 3 | 1 | mixed | [] | DecryptionUtils | 2 | Complete all missing function or method bodies. Return the complete Python file. | class DecryptionUtils:
def __init__(self, key):
self.key = key
def caesar_decipher(self, ciphertext, shift):
plaintext = ''
...
def vigenere_decipher(self, ciphertext):
decrypted_text = ''
...
def rail_fence_decipher(self, encrypted_text, rails):
fence... | true | ||
ClassEval_32 | FudanSELab/ClassEval | ClassEval_32 | class DecryptionUtils:
def __init__(self, key):
self.key = key
def caesar_decipher(self, ciphertext, shift):
plaintext = ""
for char in ciphertext:
if char.isalpha():
if char.isupper():
ascii_offset = 65
else:
... | import unittest
class DecryptionUtilsTestCaesarDecipher(unittest.TestCase):
def test_caesar_decipher(self):
d = DecryptionUtils('key')
self.assertEqual(d.caesar_decipher('ifmmp', 1), 'hello')
def test_caesar_decipher_2(self):
d = DecryptionUtils('key')
self.assertEqual(d.caesa... | [{"method_name": "caesar_decipher", "method_description": "def caesar_decipher(self, ciphertext, shift):\n \"\"\"\n Deciphers the given ciphertext using the Caesar cipher\n :param ciphertext: The ciphertext to decipher,str.\n :param shift: The shift to use for decryption,int.\n :retur... | 3 | 1 | mixed | [] | DecryptionUtils | 3 | Implement the complete class. Return the complete Python file. | """This is a class that provides methods for decryption, including the Caesar cipher, Vigenere cipher, and Rail Fence cipher.
Required methods (implement on the class; order is not specified):
- `__init__(self, key)`
- `caesar_decipher(self, ciphertext, shift)`: Deciphers the given ciphertext using the Caesar cipher
-... |
def __init__(self, key):
self.key = key
def caesar_decipher(self, ciphertext, shift):
plaintext = ''
for char in ciphertext:
if char.isalpha():
if char.isupper():
ascii_offset = 65
else:
ascii_offset = ... | true | |
ClassEval_33 | FudanSELab/ClassEval | ClassEval_33 | class DiscountStrategy:
def __init__(self, customer, cart, promotion=None):
self.customer = customer
self.cart = cart
self.promotion = promotion
self.__total = self.total()
def total(self):
self.__total = sum(item['quantity'] * item['price'] for item in self.cart)
... | import unittest
class DiscountStrategyTestTotal(unittest.TestCase):
def test_total_1(self):
customer = {'name': 'John Doe', 'fidelity': 1200}
cart = [{'product': 'product1', 'quantity': 10, 'price': 20.0},
{'product': 'product2', 'quantity': 5, 'price': 10.0}]
order = Disco... | [{"method_name": "total", "method_description": "def total(self):\n \"\"\"\n Calculate the total cost of items in the cart.\n :return: float, total cost of items\n >>> customer = {'name': 'John Doe', 'fidelity': 1200}\n >>> cart = [{'product': 'product', 'quantity': 14, 'price': 23.5}... | 5 | 5 | sequential | [] | DiscountStrategy | 1 | Complete all missing function or method bodies. Return the complete Python file. | """This is a class that allows to use different discount strategy based on shopping credit or shopping cart in supermarket."""
class DiscountStrategy:
"""
This is a class that allows to use different discount strategy based on shopping credit or shopping cart in supermarket.
"""
def __init__(self, cus... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.