task_id string | skeleton string | test string | solution_code string | import_statement list | class_description string | class_name string | test_classes list | class_constructor string | fields list | methods_info list |
|---|---|---|---|---|---|---|---|---|---|---|
ClassEval_0 | import logging
import datetime
class AccessGatewayFilter:
"""
This class is a filter used for accessing gateway filtering, primarily for authentication and access log recording.
"""
def __init__(self):
pass
def filter(self, request):
"""
Filter the incoming request based o... | 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... | 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 logging",
"import datetime"
] | """
This class is a filter used for accessing gateway filtering, primarily for authentication and access log recording.
"""
| AccessGatewayFilter | [
"AccessGatewayFilterTestFilter",
"AccessGatewayFilterTestIsStartWith",
"AccessGatewayFilterTestGetJwtUser",
"AccessGatewayFilterTest"
] | class AccessGatewayFilter:
def __init__(self):
pass
| [] | [
{
"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 ... |
ClassEval_1 | 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, radius):
"""
Initialize the radius for shapes.
:param radius: float
"""
self.radius... | 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... | 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 math"
] | """
This is a class for calculating the area of different shapes, including circle, sphere, cylinder, sector and annulus.
"""
| AreaCalculator | [
"AreaCalculatorTestCalculateCircleArea",
"AreaCalculatorTestCalculateSphereArea",
"AreaCalculatorTestCalculateCylinderArea",
"AreaCalculatorTestCalculateSectorArea",
"AreaCalculatorTestCalculateAnnulusArea",
"AreaCalculatorTestCalculateMain"
] | class AreaCalculator:
def __init__(self, radius):
"""
Initialize the radius for shapes.
:param radius: float
"""
self.radius = radius
| [
"self.radius"
] | [
{
"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_ar... |
ClassEval_2 | 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.requried is a set that stores the required arguments
... | 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... | 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('--'):
... | [] | """
This is a class for parsing command line arguments to a dictionary.
"""
| ArgumentParser | [
"ArgumentParserTestParseArguments",
"ArgumentParserTestGetArgument",
"ArgumentParserTestAddArgument",
"ArgumentParserTestConvertType",
"ArgumentParserTestMain"
] | class ArgumentParser:
def __init__(self):
"""
Initialize the fields.
self.arguments is a dict that stores the args in a command line
self.requried is a set that stores the required arguments
self.types is a dict that stores type of every arguments.
>>> parser.argumen... | [
"self.arguments",
"self.required",
"self.types"
] | [
{
"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... |
ClassEval_3 | import itertools
class ArrangementCalculator:
"""
The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
"""
def __init__(self, datas):
"""
Initializes the ArrangementCalculator object with a list of datas.
:param data... | 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... | 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 itertools"
] | """
The Arrangement class provides permutation calculations and selection operations for a given set of data elements.
"""
| ArrangementCalculator | [
"ArrangementCalculatorTestCount",
"ArrangementCalculatorTestCountAll",
"ArrangementCalculatorTestSelect",
"ArrangementCalculatorTestSelectAll",
"ArrangementCalculatorTestFactorial",
"ArrangementCalculatorTest"
] | class ArrangementCalculator:
def __init__(self, datas):
"""
Initializes the ArrangementCalculator object with a list of datas.
:param datas: List, the data elements to be used for arrangements.
"""
self.datas = datas
| [
"self.datas"
] | [
{
"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 :p... |
ClassEval_4 | class AssessmentSystem:
"""
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.
"""
def __init__(self):
"""
Initialize the students dict in assessment system.
"""
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... | 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.... | [] | """
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.
"""
| AssessmentSystem | [
"AssessmentSystemTestAddStudent",
"AssessmentSystemTestAddCourseScore",
"AssessmentSystemTestGetGPA",
"AssessmentSystemTestGetAllStudentsWithFailCourse",
"AssessmentSystemTestGetCourseAverage",
"AssessmentSystemTestGetTopStudent",
"AssessmentSystemTestMain"
] | class AssessmentSystem:
def __init__(self):
"""
Initialize the students dict in assessment system.
"""
self.students = {}
| [
"self.students"
] | [
{
"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... |
ClassEval_5 | '''
# This class is an automatic guitar simulator that can interpret and play based on the input guitar sheet music.
class AutomaticGuitarSimulator:
def __init__(self, text) -> None:
"""
Initialize the score to be played
:param text:str, score to be played
"""
self.play_text... | 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):
... | 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... | [] | """
This class is an automatic guitar simulator that can interpret and play based on the input guitar sheet music.
"""
| AutomaticGuitarSimulator | [
"AutomaticGuitarSimulatorTestInterpret",
"AutomaticGuitarSimulatorTestDisplay",
"AutomaticGuitarSimulatorTest"
] | class AutomaticGuitarSimulator:
def __init__(self, text) -> None:
"""
Initialize the score to be played
:param text:str, score to be played
"""
self.play_text = text
| [
"self.play_text"
] | [
{
"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 l... |
ClassEval_6 | class AvgPartition:
"""
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.
"""
def __init__(self, lst, limit):
"""
Initialize the class with the given list and the number of ... | 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... | 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... | [] | """
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.
"""
| AvgPartition | [
"AvgPartitionTestSetNum",
"AvgPartitionTestGet",
"AvgPartitionTestMain"
] | class AvgPartition:
def __init__(self, lst, limit):
"""
Initialize the class with the given list and the number of partitions, and check if the number of partitions is greater than 0.
"""
self.lst = lst
self.limit = limit
| [
"self.limit",
"self.lst"
] | [
{
"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.se... |
ClassEval_7 | 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.
"""
self.stack = []
self.left_brackets... | 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... | 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... | [] | """
This is a class that checks for bracket matching
"""
| BalancedBrackets | [
"BalancedBracketsTestClearExpr",
"BalancedBracketsTestCheckBalancedBrackets",
"BalancedBracketsTestMain"
] | class BalancedBrackets:
def __init__(self, expr):
"""
Initializes the class with an expression.
:param expr: The expression to check for balanced brackets,str.
"""
self.stack = []
self.left_brackets = ["(", "{", "["]
self.right_brackets = [")", "}", "]"]
... | [
"self.expr",
"self.left_brackets",
"self.right_brackets",
"self.stack"
] | [
{
"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":... |
ClassEval_8 | 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, balance=0):
"""
Initializes a bank account object with an attribute balance, default value is 0.
"""
se... | 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... | 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 ... | [] | """
This is a class as a bank account system, which supports deposit money, withdraw money, view balance, and transfer money.
"""
| BankAccount | [
"BankAccountTestDeposit",
"BankAccountTestWithdraw",
"BankAccountTestViewBalance",
"BankAccountTestTransfer",
"BankAccountTest"
] | class BankAccount:
def __init__(self, balance=0):
"""
Initializes a bank account object with an attribute balance, default value is 0.
"""
self.balance = balance
| [
"self.balance"
] | [
{
"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 amoun... |
ClassEval_9 | class BigNumCalculator:
"""
This is a class that implements big number calculations, including adding, subtracting and multiplying.
"""
@staticmethod
def add(num1, num2):
"""
Adds two big numbers.
:param num1: The first number to add,str.
:param num2: The second numb... | 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... | 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(... | [] | """
This is a class that implements big number calculations, including adding, subtracting and multiplying.
"""
| BigNumCalculator | [
"BigNumCalculatorTestAdd",
"BigNumCalculatorTestSubtract",
"BigNumCalculatorTestMultiply",
"BigNumCalculatorTestMain"
] | class BigNumCalculator:
| [] | [
{
"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()... |
ClassEval (modernised)
A lightly patched fork of FudanSELab/ClassEval, the 100-task class-level Python code generation benchmark, fixed so that it still runs correctly on a current Python and a current NumPy.
The benchmark itself is unchanged. Every patch either repairs a test that no
implementation could pass, or repairs the reference solution. No task was made
easier, no prompt (skeleton) was touched, and nothing about what a model is
asked to write has changed.
| upstream | this fork | |
|---|---|---|
| classes whose reference solution passes all its tests | 96 / 100 | 100 / 100 |
| test methods passed by the reference solutions | 2182 / 2196 | 2196 / 2196 |
Measured on CPython 3.13 and 3.14, NumPy 2.x, in a network-isolated sandbox.
What was changed
Six edits across five tasks. Schema, task ids and field names are identical to upstream.
Tests that no implementation could pass
- ClassEval_17 (
CalendarUtil) — a time bomb.get_upcoming_events()filters onevent['start_time'] >= datetime.now(), but the test hard-codes a 2024-01-02 event as the "upcoming" one, so the task became unpassable once the wall clock passed that date. The event now sits atdatetime.now().year + 1; the companion 2023 event, which must stay in the past, is untouched. - ClassEval_31 (
DataStatistics4) —assertEqualon a Pearson correlation coefficient. NumPy 2.x returns0.9819805060619655against a recorded0.9819805060619659: a 4-ULP difference, the same number to 15 significant figures. NowassertAlmostEqual. - ClassEval_48 (
IpUtil) — asserted that a reverse DNS lookup of0.0.0.0returns'LAPTOP-2CS86KUM', the dataset author's own machine name. This could never pass on any other computer. The assertion now expectsNone, which is what the lookup yields when it fails. This is the one patch that genuinely weakens a test: no portable replacement asserting a successful reverse lookup exists.
Reference solutions only (models are unaffected)
- ClassEval_51 (
KappaCalculator) — two independent NumPy 2.0 breakages:np.matwas removed (nownp.asmatrix, at both call sites), andfloat()on a 1×1 matrix is no longer allowed (now indexes[0, 0]explicitly). The second only surfaces once the first is fixed. - ClassEval_58 (
MinesweeperGame) — the referencegenerate_mine_sweeper_mapdrew mine coordinates without checking for collisions, so two mines could land on the same cell and the board would contain fewer thankmines. It failed its own test about 30% of the time (measured: 21/30 passes across 30 runs). Now retries on collision, with a guard against looping on a full board.
Known remaining quirks
Not patched, because fixing them would change what the model is shown or is metadata rather than content:
- ClassEval_69's
methods_infomapsmerge_pdfstoTestPDFHandler, a fixture-only class with zero test methods. This caps upstream's method-level metric at 409/410 for any submission, including ground truth. - ClassEval_22 / _43 / _46 have malformed skeletons. That is prompt text — patching it would change the task.
- ClassEval_44 selects its parser by string (
BeautifulSoup(html, 'lxml')), solxmlis a hard dependency that appears in no import statement and is absent from upstream'srequirements.txt. Install it or that task drops from 23/23 to 7/23. - ClassEval_69's test imports
PdfFileReaderfromPyPDF2, a name the successor packagepypdfremoved.PyPDF2cannot be substituted.
Running it
Reproduced by llama-eval in llama.cpp, which executes generated classes in a
sandboxed venv (no Docker) and reports class-level and method-level scores:
python3 llama-eval.py --server http://localhost:8033 --model my-model \
--dataset classeval --n_predict 4096 --temperature 0
Notes for anyone building their own runner:
- Do not execute as uid 0. ClassEval_50 asserts that writing to a
chmod 0444file fails; root bypasses permission bits, so it silently scores 14/16. - Give each task its own working directory — 15 tasks write files, all cwd-relative, and the names collide.
- Seed the global RNG before each test if you want reproducible verdicts.
gensimpublishes no wheel past cp313. Only two pure-Python APIs are used (utils.decode_htmlentities,matutils.unitvec), so a small shim covers 3.14.- NLTK needs exactly
punkt_tab,averaged_perceptron_tagger_engandwordnet(~33 MB). These are the modern names; the dataset asks for the renamedpunkt/averaged_perceptron_tagger.
Licence and attribution
Original work: FudanSELab/ClassEval, from "ClassEval: A Manually-Crafted Benchmark for Evaluating LLMs on Class-level Code Generation" (arXiv:2308.01861). Upstream distributes the code under MIT and the data under CC BY-NC 4.0; this modified dataset is redistributed under the same CC BY-NC 4.0 terms.
This is a modified version. For the unmodified benchmark, use FudanSELab/ClassEval.
- Downloads last month
- -