Dataset Viewer
Auto-converted to Parquet Duplicate
task_id
stringlengths
11
12
skeleton
stringlengths
929
4.57k
test
stringlengths
1.48k
20.1k
solution_code
stringlengths
496
3.91k
import_statement
sequencelengths
0
4
class_description
stringlengths
69
249
methods_info
listlengths
2
10
class_name
stringlengths
4
24
test_classes
sequencelengths
2
11
class_constructor
stringlengths
15
1.13k
fields
sequencelengths
0
9
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. """
[ { "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 ...
AccessGatewayFilter
[ "AccessGatewayFilterTestFilter", "AccessGatewayFilterTestIsStartWith", "AccessGatewayFilterTestGetJwtUser", "AccessGatewayFilterTest" ]
class AccessGatewayFilter: def __init__(self): pass
[]
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. """
[ { "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...
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" ]
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. """
[ { "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...
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" ]
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. """
[ { "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...
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" ]
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. """
[ { "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...
AssessmentSystem
[ "AssessmentSystemTestAddStudent", "AssessmentSystemTestAddCourseScore", "AssessmentSystemTestGetGPA", "AssessmentSystemTestGetAllStudentsWithFailCourse", "AssessmentSystemTestGetCourseAverage", "AssessmentSystemTestGetTopStudent", "AssessmentSystemTestMain" ]
class AssessmentSystem: def __init__(self): """ Initialize the students dict in assessment system. """ self.students = {}
[ "self.students" ]
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. """
[ { "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...
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" ]
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. """
[ { "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...
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" ]
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 """
[ { "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":...
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" ]
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. """
[ { "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...
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" ]
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. """
[ { "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()...
BigNumCalculator
[ "BigNumCalculatorTestAdd", "BigNumCalculatorTestSubtract", "BigNumCalculatorTestMultiply", "BigNumCalculatorTestMain" ]
class BigNumCalculator:
[]
End of preview. Expand in Data Studio

YAML Metadata Warning:The task_categories "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other

Dataset Card for FudanSELab ClassEval

Dataset Summary

We manually build ClassEval of 100 class-level Python coding tasks, consists of 100 classes and 412 methods, and average 33.1 test cases per class.

For 100 class-level tasks, diversity is maintained by encompassing these tasks over a wide spectrum of topics, including Management Systems, Data Formatting, Mathematical Operations, Game Development, File Handing, Database Operations and Natural Language Processing.

For 412 methods, they have been constructed with diverse dependencies, including (i) Library Dependency, where the methods rely on specific external libraries; (ii) Field Dependency, in which the methods are contingent on class instance variables, or fields; (iii) Method Dependency, where the methods are dependent on other methods within the same class; and (iv) Standalone, wherein the methods operate independently without reliance on fields, other methods, or external libraries.

Languages

The programming language is Python. The natural language used in the comments and docstrings is English.

Dataset Structure

from datasets import load_dataset
dataset = load_dataset("FudanSELab/ClassEval")

DatasetDict({
    test: Dataset({
        features: ['task_id', 'skeleton', 'test', 'solution_code', 'import_statement', 'class_description', 'methods_info', 
'class_name', 'test_classes', 'class_constructor', 'fields'],
        num_rows: 100
    })
})

Data Fields

The specific data fields for each task are delineated as follows:

  • task_id: the unique identifier for each task.

  • skeleton: the class skeleton, including all input descriptions in our class-level coding tasks.

  • test: all test cases for the whole class.

  • solution_code: the ground-truth class-level code for each task.

More fine-grained class-level information from the class skeleton, including:

  • import_statement: the import statements for each task.

  • class_name: the name of the class.

  • class_description: a concise description of the purpose and functionality of the class.

  • class_constructor: the whole constructor of the class.

  • fields: the fields defined in the class_constructor.

Detailed information for each method in the "methods_info" field, including:

  • method_name: the method signature.

  • method_input: the method contract design, including all input descriptions in the method.

  • test_code: the test cases for the method.

  • solution_code: the ground-truth method-level code.

  • dependencies: the dependency information of the method.

Data Splits

The dataset only consists of a test split with 100 samples.

Dataset Creation

Source Data

Manually-crafted

Additional Information

Licensing Information

This repository is under MIT license. But the data is distributes through CC BY-NC 4.0 license.

Citation Information

@misc{du2023classeval,
      title={ClassEval: A Manually-Crafted Benchmark for Evaluating LLMs on Class-level Code Generation}, 
      author={Xueying Du and Mingwei Liu and Kaixin Wang and Hanlin Wang and Junwei Liu and Yixuan Chen and Jiayi Feng and Chaofeng Sha and Xin Peng and Yiling Lou},
      year={2023},
      eprint={2308.01861},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

Contributions

Xueying Du xueyingdu21@m.fudan.edu.cn

Mingwei Liu liumingwei@fudan.edu.cn

Kaixin Wang kxwang23@m.fudan.edu.cn

Hanlin Wang wanghanlin23@m.fudan.edu.cn

Junwei Liu jwliu22@m.fudan.edu.cn

Yixuan Chen 23212010005@m.fudan.edu.cn

Jiayi Feng 23210240148@m.fudan.edu.cn

Chaofeng Sha cfsha@fudan.edu.cn

Xin Peng pengxin@fudan.edu.cn

Yiling Lou yilinglou@fudan.edu.cn

Downloads last month
4,003

Space using FudanSELab/ClassEval 1

Paper for FudanSELab/ClassEval