instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a function that calculates the absolute position of an element within its container. The function takes two parameters: `containerRect` and `container`, representing the bounding rectangle of the container and the container element itself, respectively. The `containerRect` object contai...
codefeedback
You are tasked with creating a Python script that packages a set of commands into a release archive. The script should accept command-line arguments for the file containing the commands, the version name for the release, and the destination directory for the archive. The commands are stored in a JSON file in key/value ...
codefeedback
You are tasked with implementing a TypeScript function that manages a tree data structure. The tree consists of nodes of different types, and the function needs to handle various operations on these nodes. The code snippet provided gives a glimpse of the data structure and a helper function used in the implementation. ...
codefeedback
You are tasked with implementing a function that processes a given HTML element and extracts specific attributes from it. The function should handle potential errors and return the extracted attribute value if successful. If an error occurs during the extraction process, the function should return a default value. You...
codefeedback
You are tasked with implementing a Python function that checks the validity of a given file path and determines if the file is accessible to the current user. The function should return a boolean value indicating whether the file exists and is accessible. The function signature is: ```python def is_file_accessible(fil...
codefeedback
You are given an image represented as a 2D array and a patch size. The image has a shape of (rows, columns), and the patch size is an integer representing the side length of a square patch. Your task is to write a function to extract a random patch of the specified size from the image. If the image is smaller than the ...
codefeedback
You are tasked with implementing a custom type checking decorator in Python. The decorator should enforce type checking for the arguments and return value of a function based on specified type annotations. You are required to create a `typed` decorator that can be used to annotate functions with type information and ra...
codefeedback
You are tasked with implementing a Python class that extends functionality from two different modules. The first module, `linear`, contains a class called `Linear`, while the second module, `module`, contains a class called `QATModule`. Your task is to create a new class called `Linear` that inherits from `Float.Linear...
codefeedback
You are tasked with creating a PHP class that handles the storage of notes in a web application. The class should be able to save notes with the following attributes: mime type, username, content file, filename, and folder ID. Additionally, the class should be able to retrieve an existing note if it exists, or create a...
codefeedback
You are tasked with implementing a function that processes a list of strings and returns a tuple containing the processed list of strings and a tuple of two integers. The function should take a list of strings as input and perform the following operations: 1. Remove any duplicate strings from the input list. 2. Sort th...
codefeedback
You are tasked with implementing a thread-safe class that manages time ranges and provides methods to protect and unprotect these ranges for concurrent access. The class should allow clients to protect time ranges of the form [t_min, +∞[ and ensure that any attempt to access the time range ]-∞, t[ is delayed until ]-∞,...
codefeedback
You are tasked with creating a Python class to manage a brewing controller for a homebrewing system. The controller is responsible for managing various stages of the brewing process, such as sparging, mashing, and boiling. Your task is to implement the missing methods and attributes of the `BrewController` class based ...
codefeedback
You are tasked with implementing a DNS provisioner for a cloud infrastructure management system. The `DnsProvisionerVubercool` class is responsible for provisioning and deleting hostnames in the DNS zone. The `client_` member variable represents the client used to communicate with the DNS service. Your task is to comp...
codefeedback
You are tasked with implementing a settings management system for a music application. The system should allow for the storage and retrieval of various settings, as well as updating the display with the latest setting values. The provided code snippet is part of a settings management module in the application. It incl...
codefeedback
You are given a code snippet that defines a function `diameter` to calculate the diameter of a graph. The function takes two parameters: a graph represented by `JsGraph` and a function `edge_distance` that calculates the distance between two edges. The `diameter` function uses the Warshall-Floyd algorithm to find the s...
codefeedback
You are tasked with implementing a Python function that generates a synthetic dataset using the Gaussian Mixture Model (GMM) algorithm. The GMM algorithm is a probabilistic model that assumes all the data points are generated from a mixture of several Gaussian distributions with unknown parameters. Your function should...
codefeedback
You are tasked with creating a Rust module that provides analysis and manipulation of a Federated Byzantine Agreement System (FBAS). The FBAS consists of nodes and quorum sets, where each node has a unique identifier (NodeId) and a set of nodes (QuorumSet) that it trusts. Your goal is to implement a function that filte...
codefeedback
You are working on a backend system for an e-commerce platform, and you need to implement a service for managing a user's shopping cart. The service will have methods for updating, removing, and clearing items from the cart. You are given a code snippet representing the interface for this service: ```csharp public int...
codefeedback
You are tasked with implementing a ledger transaction operation in Swift. The ledger transaction operation is a part of a larger system that involves Bluetooth Low Energy (BLE) communication with a hardware device. The provided code snippet is a part of the ledger transaction operation class, which conforms to the Ledg...
codefeedback
You are tasked with implementing a custom memory management system for a mobile application. The system should track the deallocation of view controllers and execute specific cleanup code when a view controller is deallocated. You are provided with a code snippet that includes a `ParentVC` class, which is a subclass o...
codefeedback
You are tasked with creating a program that processes a JSON file containing data about various products. Each product is represented as a JSON object with attributes such as name, price, and category. Your program needs to read the JSON file, parse the data, and perform specific operations based on the product informa...
codefeedback
You are tasked with creating a Python class that parses and manipulates configuration data using the `cfgenvy` library. The `cfgenvy` library provides a `Parser` class for parsing configuration data from various sources, such as YAML files, environment variables, and command-line arguments. Your task is to create a su...
codefeedback
You are tasked with creating a Python package management system that can handle dependencies between modules. Each module can have dependencies on other modules, and the system should be able to resolve these dependencies and load the modules in the correct order. You are given the following code snippet from the pack...
codefeedback
You are tasked with implementing a function that reshapes a given 1D array into a 2D array with a specified number of rows. The function should take the 1D array and the number of rows as input and return the reshaped 2D array. If the input array cannot be reshaped to the specified number of rows while maintaining the ...
codefeedback
You are tasked with creating a program that interfaces between the Lightweight Communications and Marshalling (LCM) system and the Robot Operating System (ROS). The LCM system is a lightweight messaging system for communication between software components, while ROS is a flexible framework for writing robot software. Y...
codefeedback
You are given a rectangular grid of size A x B. Each cell in the grid represents a unit square. You need to find the number of rectangles that can be formed within this grid such that the sides of the rectangles are aligned with the grid lines and the rectangles do not cover the entire grid. Write a program that takes...
codefeedback
You are working on a computer vision project that involves drawing anchors on an image to assist in object detection. The code snippet provided is a part of this project and involves image processing and anchor generation. Your task is to implement a function that calculates the total number of anchors created based o...
codefeedback
You are tasked with implementing a real-time object detection system using the YOLO (You Only Look Once) algorithm and OpenCV. The YOLO algorithm is a state-of-the-art, real-time object detection system that can detect multiple objects in an image or video stream. Your goal is to create a Python program that utilizes t...
codefeedback
You are tasked with creating a program to analyze student data from a database. The given code snippet is part of a PHP program that interacts with a database using the CodeIgniter framework. The program retrieves information about students' grades and counts the total number of students and the number of students with...
codefeedback
You are tasked with implementing a Python class that simulates a simple graph data structure. The class should support adding nodes and edges, as well as performing depth-first search (DFS) and breadth-first search (BFS) traversal algorithms on the graph. Your task is to complete the implementation of the `Graph` clas...
codefeedback
You are tasked with implementing a class that represents a blog post in a content management system. The class should have properties for the body of the post, SEO description, SEO title, excerpt, thumbnail URL, tags, category, and a safe name generated from the post's name. You need to create a C# class named `BlogPo...
codefeedback
You are tasked with implementing a form component rendering system that supports input field addons such as prepend and append elements. The system should be able to render input fields with these addons based on the configuration settings and input parameters. Your goal is to write a method that can render the input c...
codefeedback
You are tasked with implementing a simplified version of a request manager for a health data API. The provided code snippet outlines the basic structure of the `Method` class and its `execute` method. Your task is to create a Python class that extends the functionality of the `Method` class and implements the `makerequ...
codefeedback
You are tasked with implementing a function that processes a given JavaScript code snippet and extracts the default export from a module. The code snippet will be provided as a string, and you need to extract and return the default export identifier. Write a function `extractDefaultExport` that takes a single paramete...
codefeedback
You are tasked with implementing a Python class to represent a GZEntry, which is a data structure for a compressed file entry in the Gzip format. The GZEntry contains various fields such as comments, flags, compression method, compression flags, lengths, CRC32 checksum, and offsets. Your task is to create a Python cla...
codefeedback
You are tasked with creating a function that interacts with a blockchain network. The function is responsible for querying a chaincode on a specific channel and processing the response. However, there is a bug in the existing code that causes the function to return an error response instead of the expected result. Your...
codefeedback
You are tasked with creating a Python function that processes a JSON file containing information about different scripts to be executed in a specific order. Each script is represented as a dictionary with the following keys: "name", "path", and "dependencies". The "name" key holds the name of the script, the "path" key...
codefeedback
You are tasked with implementing a simplified version of the AES-CBC encryption and decryption algorithm. The AES-CBC (Advanced Encryption Standard - Cipher Block Chaining) is a widely used symmetric encryption algorithm. In this problem, you will be given a set of functions and their usage in a testing context. Your t...
codefeedback
You are tasked with creating a Python package manager tool that can handle dependencies and execute console scripts. Your tool should be able to parse a configuration file and install the required packages, as well as execute any associated console scripts. Your tool should read a configuration file in the following f...
codefeedback
You are tasked with implementing a custom attribute macro in Rust to fix a hidden lifetime bug in the given code snippet. The code snippet contains an asynchronous function `bar` that takes a reference to `()` and a trait object of type `dyn Send` as arguments. Your task is to create a custom attribute macro, `fix_hidd...
codefeedback
You are tasked with implementing a function that processes a list of web page data and returns a dictionary containing the count of unique words on each page. The function should take a list of strings, where each string represents the content of a web page, and return a dictionary where the keys are the page numbers (...
codefeedback
You are tasked with creating a programming problem related to Swift generics and protocols. The problem will focus on understanding and working with generic types and protocol constraints in Swift. You are given the following code snippet as a starting point for the problem: ```swift import Foundation import VoodooLa...
codefeedback
You are tasked with implementing a Python function to perform exponential regression on a given set of error rates and then using the regression results to extrapolate the annual decay of the error rate. The function should take a pandas DataFrame containing two columns: the first column represents the timestamps of th...
codefeedback
You are tasked with implementing a function to parse a comma-separated line of text and extract specific information from it. The function should take a string `line` containing comma-separated values and store these values in a list of tokens. After parsing the line, the function should extract an integer `hostid` fro...
codefeedback
You are tasked with implementing a Python class for shape alignment and transformation. The class, named `ShapeAligner`, is responsible for aligning a new shape with a previous shape using pose parameters and performing transformations on the shapes. Your task is to complete the implementation of the `ShapeAligner` cla...
codefeedback
You are tasked with implementing a function to convert a given integer to a byte array using a specified byte order and then converting the byte array back to the original integer. Write a Python function called `int_to_byte` that takes in three parameters: - `num` (integer): The integer to be converted to a byte arra...
codefeedback
You are tasked with implementing a function to calculate the spatial dissonance reduction (SDR) of two audio signals. The SDR measures the amount of interference between the two signals, with a lower value indicating less interference and better separation. The given code snippet provides a starting point for the imple...
codefeedback
You are tasked with implementing a class hierarchy for handling cell events in a simulation system. The provided code snippet is a partial definition of a class `CellSolidFilterEvent` that inherits from the `CellEvent` class. The `CellSolidFilterEvent` class has a constructor that takes a string `id` and an optional bo...
codefeedback
You are working for a retail company that sells various products. The company has a database table named `sales` that stores information about the sales of different products. The table has the following columns: - `id_produk` (integer): the unique identifier for each product - `month` (integer): the month in which the...
codefeedback
You are working on a project to defend against adversarial attacks on machine learning models. As part of this project, you need to implement a function to generate adversarial examples for a given set of target classes. The code snippet provided is a part of the implementation and involves the following steps: 1. Init...
codefeedback
You are tasked with creating a script to process and analyze data from the Fashion-MNIST dataset. The Fashion-MNIST dataset is a collection of 28x28 grayscale images of 10 different types of clothing items. Your script should read a sample request from a JSON file, process the data, and then output the result. The sam...
codefeedback
You are tasked with implementing a URL shortening service that takes a long URL and converts it into a shorter, more manageable form. To achieve this, you need to create a class that handles the conversion of URLs to their corresponding file system paths. The class should have the following attributes: - `max_len`: An ...
codefeedback
You are tasked with creating a script to automate the installation process for a software tool called "Osmedeus." The installation script should perform the following steps: 1. Display a banner indicating the start of the installation process, including the name of the software being installed. 2. Set executable permis...
codefeedback
You are tasked with creating a program that analyzes a software license file to extract specific information. The license file follows a specific format, and your program needs to parse the file and extract the relevant details. The license file format is as follows: ``` License Information: Name: [License Holder's Na...
codefeedback
You are tasked with creating a script to automate the process of checking for the availability of the latest release of a software package on GitHub and downloading it if it's different from the currently installed version. Your script should also ensure that Docker is running and that the user is logged in to Docker H...
codefeedback
You are tasked with creating a test case for a Django web application that involves creating an event page with a remote location. The code snippet provided includes an assertion to check the type of the location page and a test function to create an event page with a remote location. Your task is to write a test case ...
codefeedback
You are tasked with creating a Python function that processes a list of strings representing Python code and extracts all unique methods used from the `selenium` package. The function should return a sorted list of unique method names. The function signature should be: ```python def extract_selenium_methods(code_snipp...
codefeedback
You are tasked with implementing a Python class that represents a JSON element. The class should support various operations such as adding, updating, and deleting key-value pairs, as well as retrieving the value associated with a given key. Additionally, the class should be able to serialize the JSON element into a str...
codefeedback
You are tasked with creating a Python script that interacts with an Elasticsearch database to perform search operations. Your goal is to write a function that takes a search query as input and returns the results from the Elasticsearch database. You are provided with a partially completed Python script that includes t...
codefeedback
You are tasked with creating a Python class for managing movie data in a MongoDB database. The class should include methods for adding a new movie, retrieving movie details, and updating movie information. You will need to use the `pymongo` library to interact with the MongoDB database. Your task is to complete the `M...
codefeedback
You are given a table `Sales` with the following structure and sample data: ``` +--------------+--------------+----------+ | product_name | sale_date | units | +--------------+--------------+----------+ | 3 | 2020-02-24 | 3 | | 4 | 2020-03-01 | 20 | | 4 | 2020-03...
codefeedback
You are tasked with creating a Python decorator that ensures a function is only executed on a specific operating system version and architecture. The decorator should take in the minimum SDK level and the architecture as parameters and should raise an exception if the conditions are not met. Your task is to implement ...
codefeedback
You are tasked with implementing a macro in Rust that checks if a given type is a variant of a specific enum or enum-like type. The macro should take two arguments: the type to be checked and the enum type. The macro should return a boolean value indicating whether the given type is a variant of the specified enum type...
codefeedback
You are tasked with implementing a Python class that performs a specific operation within a data processing pipeline. The class, `CreateDatabase`, is a subclass of `PipelineStep` and is responsible for creating a database using the provided `DB` object. Your task is to complete the implementation of the `CreateDatabase...
codefeedback
You are tasked with implementing a cookie consent banner for a website using HTML, CSS, and JavaScript. The banner should display a message, a link to the terms of service, and a button to accept the cookies. Additionally, the banner should be displayed at the bottom of the page and should be dismissible once the user ...
codefeedback
You are given a code snippet that processes a collection of elements and performs certain operations on it. Your task is to understand the code and implement a similar functionality in a programming language of your choice. Write a function or method that takes a list of integers `A` and an integer `d` as input. The f...
codefeedback
You are given a list of color names and their corresponding hexadecimal values. Your task is to write a function that takes a color name as input and returns its corresponding hexadecimal value. If the input color name is not found in the list, the function should return "Unknown color". The list of color names and th...
codefeedback
You are tasked with implementing a custom error handling mechanism in Rust for a specific use case. Your goal is to create a custom error type and a function to raise an exception with a given message. The custom error type should encapsulate the error message and be convertible to the Erlang NIF term type (`ERL_NIF_TE...
codefeedback
You are given a code snippet that simulates a blockchain smart contract interaction. The code is related to a decentralized finance (DeFi) protocol where users can deposit and withdraw liquidity provider (LP) tokens. The code snippet includes assertions about the balances of different addresses and the withdrawal of LP...
codefeedback
You are tasked with implementing a function to parse a string and extract specific parts based on certain criteria. The function `parse` takes a string `v` as input and returns a list of tuples. Each tuple contains an integer and an optional string. The integer represents the number of separators encountered before the...
codefeedback
You are working on a natural language processing (NLP) project and need to implement a custom attention mechanism for a sequence-to-sequence model. The model consists of an encoder and a decoder, and you have access to the encoder's last hidden state (`h_s`), the attention mask (`mask_tensor`), and the indexed tokens f...
codefeedback
You are tasked with implementing a simple event handling system in Python. Your goal is to create a class that allows subscribers to register for events and for the event publisher to notify all subscribers when an event occurs. Create a class `EventPublisher` with the following methods: - `__init__(self)`: Initialize...
codefeedback
You are working on a project that involves testing a Rust library for rendering Markdown content. The library provides two functions: `render_markdown` and `render`. The `render_markdown` function takes a Markdown string as input and returns the corresponding HTML string. The `render` function is used to render a Markd...
codefeedback
You are given a string containing a series of parentheses, brackets, and curly braces. Your task is to determine if the string is valid, meaning that the parentheses, brackets, and curly braces are properly nested and closed. Write a function `isValidParentheses` that takes a string `s` as input and returns `true` if ...
codefeedback
You are tasked with creating a Python class that simulates a simple library management system. The class should allow users to add books to the library, borrow books, return books, and display the current inventory of books. Additionally, the class should keep track of the borrowing history for each book. Your task is...
codefeedback
You are tasked with implementing a rate limiting mechanism for a GraphQL resolver function in a Node.js application. The resolver function is responsible for handling incoming GraphQL queries and mutations. The goal is to restrict the number of requests that can be made to this resolver function within a specific time ...
codefeedback
You are tasked with implementing a function to convert the values of the FP MMX registers from a source structure to a destination structure. The source structure contains an array of values, and the FP MMX registers need to be added to the FPU state in the destination structure. The FP MMX registers are represented by...
codefeedback
You are tasked with creating a Python program that manages a blockchain network. The program should include functionality for adding new blocks to the blockchain, creating and verifying transactions, and ensuring the integrity of the blockchain through hashing and verification. Your task is to implement a class called...
codefeedback
You are tasked with implementing a memory layout analysis tool for C++ structures. Your program should be able to determine the size of a structure, including any inherited members and padding. For this problem, you will focus on analyzing the memory layout of the given C++ structure and its inheritance. Given the fol...
codefeedback
You are tasked with creating a Python script to analyze the diffusion of particles in a given trajectory file. The trajectory file contains the positions of particles at different time steps. Your script should calculate the mean squared displacement (MSD) of the particles to quantify their diffusion behavior. Your sc...
codefeedback
You are tasked with implementing a camera system for a 3D game. The camera should automatically adjust its position based on the target's position and the field of view (FOV) of the camera. The provided code snippet is a part of the camera positioning logic. The `target` is the object the camera is following, and `cam`...
codefeedback
You are given a list of points in a 2D plane, each represented as a tuple of the form (x, y, label), where x and y are the coordinates and label is a unique identifier for the point. Your task is to implement a function `closest_pair(points, distance)` that finds the closest pair of points based on a given distance fun...
codefeedback
You are tasked with implementing a Python function that calculates the sum of all prime numbers within a given range. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The function should take two integer parameters, `start` and `end`, representing the inclusive ra...
codefeedback
You are tasked with creating a Python ROS (Robot Operating System) node that subscribes to an image topic and performs color detection on the received images. The node should use the OpenCV library to process the images and identify specific colors within them. Once a color is detected, the node should publish the coor...
codefeedback
You are tasked with creating a web application using Python's Tornado framework and Pony ORM for database operations. Your goal is to build a simple RESTful API for managing a collection of books. The application should support operations such as adding a new book, retrieving a list of all books, updating a book's deta...
codefeedback
You are tasked with creating a program that parses HTML code to extract the dropdown menu items and their corresponding icons. The HTML code snippet provided represents a portion of a web page containing a dropdown menu with various items and icons. Your task is to write a function that takes this HTML code as input an...
codefeedback
You are tasked with implementing a class to handle event data parsing in a specific format. The class should be able to parse and extract data based on a predefined layout. You are given a code snippet that demonstrates the usage of the class and the expected output. Your task is to create the class `EventDataParser` ...
codefeedback
You are working on a chemical process simulation software, and you need to implement a method for calculating internal energy during a flash operation. The method `flash_press_int_energy` takes several parameters and is responsible for performing the necessary calculations. Your task is to implement the `flash_press_in...
codefeedback
You are tasked with implementing a class that simulates a virtual console with input, output, and error streams. The class should provide methods for writing to the output and error streams, as well as reading from the input stream. Additionally, the class should support redirection of these streams to in-memory buffer...
codefeedback
You are tasked with creating a secure authentication system for a web application. The system should validate an "appKey" sent via a POST request to ensure that only authorized applications can access the application's API. The "appKey" is a unique identifier assigned to each registered application. Write a PHP functi...
codefeedback
You are working on a script that executes a command and captures its standard output, standard error, and exit code. The script sets environment variables based on key-value pairs and then uses these variables to construct and execute a command. Your task is to write a function that takes in the key-value pairs, the co...
codefeedback
You are tasked with creating a script that organizes files into directories based on their file extensions. Your script should take a source directory as input and create subdirectories within it for each unique file extension found in the source directory. Then, it should move each file into the corresponding subdirec...
codefeedback
You are tasked with implementing a Java interface for a compiler that takes source code and compiles it into a form that can be executed. The interface, `Compiler`, has a single method `compile` that takes an `ObjectStoreSession`, source code as a string, and an array of parameter names as input. Your goal is to create...
codefeedback
You are working on a project that involves processing raw data to extract features and then performing post-processing evaluation on the extracted features. The feature extraction process involves loading raw features from a module called `feature_extraction`, and the post-processing evaluation is done using a function...
codefeedback
You are tasked with implementing a Python function that processes an image using a pre-trained deep learning model and returns the top predicted labels for the image. The function should take an image as input, preprocess it, make predictions using the model, and then decode the predictions to obtain the top labels. Y...
codefeedback
You are working on a text processing application that requires the calculation of the width and height of a given text string when rendered on a bitmap. To achieve this, you need to create a method that takes in the text string, font size, and maximum width, and returns the width and height of the rendered text. You h...
codefeedback
You are tasked with implementing a Python function to generate a TensorFlow record (TFRecord) file from a given frame and its detections. The function should take in the frame, detections, filename, and any additional arguments, and then encode the frame and its associated information into the TFRecord format. The prov...
codefeedback
You are working on a data analysis project and need to create a function that processes multiple input files, calibrates the results, and stores the calibrated and uncalibrated results in a pandas DataFrame. The DataFrame should have columns for "Name", "Error", "ECE" (Expected Calibration Error), "MCE" (Maximum Calibr...
codefeedback
You are tasked with implementing a Python class method for extracting attributes from an object and testing the extraction process using unit tests. You are given a code snippet that includes a method `extract` and a unit test method `test_extract_attributes`. The `extract` method is responsible for extracting attribu...
codefeedback
You are tasked with implementing a Python class that represents a geometric object in a specified dimension and on a specified embedding manifold. The class should provide methods for calculating the volume and surface area of the geometric object based on its dimension and embedding manifold. You are given the follow...
codefeedback