instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are given a Python function that processes a 2D numpy array `np_ink` representing ink strokes and a string `class_name`. The function performs two main operations: 1. Size normalization: It normalizes the size of the ink strokes by scaling them to fit within a specific range. 2. Compute deltas: It computes the diff...
codefeedback
You are tasked with implementing a function that simulates a circular buffer with a fixed size. The circular buffer should support the following operations: 1. `write(data, length)`: Write the given data to the circular buffer. If the buffer is full, overwrite the oldest data. 2. `read(length)`: Read the specified leng...
codefeedback
You are given a 2D grid representing a topographic map. Each cell in the grid contains an integer representing the height of the land at that point. A point is considered a basin if it is surrounded by higher or equal points in all cardinal directions (north, south, east, west). Your task is to find the number of basin...
codefeedback
You are tasked with implementing a text editor feature that involves manipulating text lines and syntax trees. The text editor has a `Syntax` struct with various fields, including `rev`, `language`, `tree`, `text`, `lens`, and `line_height`. The `Syntax` struct also has a method `line_of_offset` that takes an offset as...
codefeedback
You are tasked with implementing a console menu system in C#. The `ConsoleMenu` class is provided, which contains a list of `ConsoleMenuItem` objects. Each `ConsoleMenuItem` has a title and an action to be executed when the item is selected. Your task is to implement the `ConsoleMenuItem` class and its associated meth...
codefeedback
You are tasked with creating a program that processes a text file containing a list of students and their corresponding grades. Each line in the file represents a student's name followed by their grade, separated by a comma. Your program should read this file, calculate the average grade for each student, and then writ...
codefeedback
You are tasked with creating a Python program that simulates a simple task management system. The program should allow users to add tasks, view all tasks, mark tasks as completed, and exit the program. The code snippet provided below shows a function `exitProgram()` that is called when the user chooses to exit the prog...
codefeedback
You are tasked with implementing a custom decision-making system using the dynamic stack decider framework in Python. The dynamic stack decider is a system for creating complex decision-making processes by combining simple decision elements in a hierarchical manner. Each decision element represents a single decision or...
codefeedback
You are tasked with creating a script to automate the process of generating training sets for a machine learning model. The training set generation involves sourcing environment variables, loading specific modules, and executing a Python script. Your task is to write a Python script that replicates the functionality of...
codefeedback
You are tasked with creating a program to generate a specified number of simple arithmetic questions involving addition and subtraction. The program should take into account the following parameters: - The quantity of questions to generate (default: 20, maximum: 200) - The minimum and maximum numbers to be used in the...
codefeedback
You are tasked with creating a program to visualize waterfall data in a text-based format. Waterfall data is a type of visualization commonly used in performance analysis, where each "node" represents a step or event, and its position and length on the screen represent the time it took to complete. The code snippet pro...
codefeedback
You are tasked with implementing a pagination utility for a project management system. The system has a `Project` entity and a `Manager` entity, with corresponding repositories for each entity. The provided code snippet shows two methods in a service class that perform pagination for searching projects based on project...
codefeedback
You are tasked with implementing a custom folding operation for Rust syntax trees using the `syn` crate. The `impl Fold for Throws` code snippet demonstrates a partial implementation of the `Fold` trait for the `Throws` type. Your goal is to complete the implementation of the `fold_item_fn` method for the `Throws` type...
codefeedback
You are working on a space exploration project and need to process data from a spacecraft's telemetry. The telemetry data is stored in a binary file in a specific format. Each record in the file represents a snapshot of the spacecraft's state at a given time. The data structure for each record is defined by a set of fi...
codefeedback
You are tasked with creating a Python function to manage the addition of disks to a Lich storage system. The function `lichbd_add_disks` takes a single parameter `monHostname`, which represents the hostname of the monitor node in the Lich storage cluster. The function is responsible for executing two shell commands on ...
codefeedback
You are tasked with implementing a function that converts a given string into a specific format. The input string will consist of a series of words separated by spaces. Your task is to convert this input string into a new string where each word is capitalized and separated by underscores. Additionally, any non-alphanum...
codefeedback
You are tasked with implementing a class that represents a cancellation system for a service. The class should have the following methods: 1. `getCanCancel()`: This method should return a boolean value indicating whether the service can be canceled. This value is determined by specific conditions within the service. ...
codefeedback
You are given a code snippet from a Swift file named "Rx+PFS.swift". Your task is to analyze the code and identify the potential purpose or functionality of the file based on the provided information. Your task is to: 1. Analyze the given code snippet and infer the potential functionality or purpose of the "Rx+PFS.sw...
codefeedback
You are tasked with creating a Python function that processes a given JSON object and returns a list of all the keys present in the object. The JSON object will be provided as a dictionary, and it may contain nested objects and arrays. Your function should be able to handle these nested structures and extract all the k...
codefeedback
You are tasked with implementing a method to handle the creation of objects in a web application framework. The method signature is as follows: ```java void handleCreate(HttpContext context, Crud<T> crud, ModelDescription<T> modelDescription, ObjectMapper objectMapper) throws Exception; ``` In this context: - `HttpCo...
codefeedback
You are tasked with implementing a virtual key (vkey) state tracking system within the `InputManager` class. The virtual key states are represented by the following constants: - `VKEY_STATE_PRESSED` (1): Indicates that the virtual key is currently pressed. - `VKEY_STATE_HELD` (2): Indicates that the virtual key is bein...
codefeedback
You are tasked with understanding and analyzing a code snippet related to Swift metadata response functions. The code snippet provided is a part of the LLVM IR (Intermediate Representation) generated from Swift source code. Your goal is to comprehend the purpose and functionality of the code snippet and explain its sig...
codefeedback
You are tasked with implementing a simple code formatter that indents the code based on a given set of rules. The code snippet provided gives an interface for a code formatter, which includes methods for handling writes and ending the document. Your task is to create a class that implements this interface and provides ...
codefeedback
You are tasked with implementing a thread-safe node registry system in Python. The provided code snippet includes a `_NodeRegistry` class and two functions: `register_node` and `registered_nodes`. The `_NodeRegistry` class is responsible for storing and managing registered nodes, while the `register_node` function is u...
codefeedback
You are tasked with simulating a file system using Python. Your goal is to create a program that generates a random directory structure with files and folders, based on the given parameters. The program should create directories up to a maximum depth, with each directory having a random number of subdirectories and fil...
codefeedback
You are tasked with creating a TypeScript module that manages subscriptions for a digital content platform. The module should include functionality for creating and managing subscription entities, as well as entities representing digital content crates. The code snippet provided is a part of the module's export stateme...
codefeedback
You are tasked with implementing a method for a game that involves loading abstract figures onto the game board. The method signature is as follows: ```java AbstractFigur[][] loading(AbstractFigur data[][], Player player); ``` The `loading` method takes in a 2D array `data` representing the current state of the game ...
codefeedback
You are tasked with implementing a class for article recommendation based on a k-nearest neighbors (KNN) algorithm. The class, `TestArticleRecommender`, is initialized with a function that loads a corpus for testing. Additionally, the initialization involves setting the `knn_dimension` attribute using the `knn_predicti...
codefeedback
You are tasked with implementing a custom annotation processor for a Java application. The application uses annotations to mark certain methods as mandatory and requires the processor to enforce this requirement during compilation. Your task is to implement the logic for the custom annotation processor to enforce the ...
codefeedback
You are tasked with implementing a multi-head attention mechanism for a neural network model. The given code snippet is a part of the implementation of the attention mechanism. The snippet shows the initialization and computation of key and value vectors for the attention mechanism. Your task is to complete the impleme...
codefeedback
You are tasked with creating a Python function that processes a set of option files and extracts specific information from them. The option files are stored in a directory structure and contain JSON data. Your function should locate the relevant option files, read their JSON content, and extract specific information ba...
codefeedback
You are tasked with creating a script to manage logical volumes (LVs) in a volume group (VG) on a Linux system. The script should perform the following tasks: 1. Display all LVs in the specified VG along with their associated devices. 2. Remove all LVs forcefully from the specified VG. 3. Check if any device mappings a...
codefeedback
You are tasked with creating a script to automate the build process for a microservices-based application. The script should handle different build types and set appropriate options based on the build type. Given the provided code snippet, you need to complete the script by adding the necessary logic to handle the bui...
codefeedback
You are given a directed graph represented by an adjacency list and two boolean arrays `visited` and `checkedLoop`. The graph is represented as a collection of vertices and their corresponding outgoing edges. The `visited` array is used to keep track of visited vertices during a depth-first search (DFS), while the `che...
codefeedback
You are tasked with implementing a custom `Maybe` type in Rust that mimics the behavior of the `MaybeUninit` type from the standard library. The `Maybe` type should provide a safe abstraction for working with potentially uninitialized data. Your task is to define the `Maybe` type and implement the following methods fo...
codefeedback
You are tasked with creating a program that filters a list of words based on certain criteria. The program should take a list of words as input and filter out words that do not meet the specified conditions. The conditions are as follows: 1. The length of the word must be greater than or equal to a specified minimum le...
codefeedback
You are tasked with creating a program to simulate a simple traffic light control system using Java and the Apache PLC4X library. The traffic light system consists of two traffic lights, one for the main road and one for the side road. The traffic lights should alternate between red, green, and yellow states according ...
codefeedback
You are tasked with creating a PHP class that reads and processes data from a CSV file. Your class should be able to handle various operations such as reading the file, parsing the data, and providing methods to access and manipulate the data. Your task is to implement a PHP class named `CSVReader` with the following ...
codefeedback
You are tasked with creating a Python function that interacts with the Challonge API to update match scores. The function takes in a record containing match details and uses the urllib3 library to send a PUT request to the Challonge API for updating the match scores. The function then checks the response status and ret...
codefeedback
You are working on a plant species detection system that analyzes images to identify different types of plants. The system uses a check_species function to compare the density of plants within a given area and determine the dominant species. The function takes a URL for image analysis and a list of rectangles represent...
codefeedback
You are tasked with implementing a SwiftFHIRAccount class that represents a FHIR (Fast Healthcare Interoperability Resources) account. The class should have properties to store the account's ID, status, and type. Additionally, you need to implement a method to instantiate a SwiftFHIRAccount object from a JSON file. Yo...
codefeedback
You are tasked with creating a Python function that processes an image file and performs a specific transformation on it. The function should take the file path as input and return a modified image. The transformation involves converting the image to grayscale and then applying a specific filter to it. You are provide...
codefeedback
You are tasked with implementing a higher-order component (HOC) in a React application. The HOC should connect a component to the Redux store using the `connect` function from the `react-redux` library. Additionally, the HOC should map state and dispatch functions to the component using `mapStateToProps` and `mapDispat...
codefeedback
You are tasked with implementing a class that simulates a simple event-driven system. The class, `EventSystem`, should allow users to register event handlers for specific events and trigger those events with optional data. Additionally, the class should support the ability to unregister event handlers. Your task is to...
codefeedback
You are tasked with implementing a custom dependency injection compiler pass in a PHP application. In the given code snippet, a method `build` is being used to add a compiler pass to the container builder. Your task is to complete the implementation of the `StoragePass` class, which will be responsible for processing a...
codefeedback
You are tasked with implementing a permission management system for a web application. The system should grant specific permissions to different user roles based on the models and their associated database tables in the application. You are provided with a code snippet that demonstrates part of the process for generat...
codefeedback
You are tasked with implementing a rendering system for a 2D graphics engine. The system should utilize an effect framework to apply visual effects to the rendered objects. The code snippet provided demonstrates the usage of an effect to render a node's geometry. Your task is to write a function that takes the necessar...
codefeedback
You are tasked with implementing a Python class that manages movement paths for a game. The provided code snippet includes imports for two modules: `MovementPath` and `MovementPaths`. Your goal is to create a class called `PathManager` that will handle the management of movement paths within the game. The `MovementPat...
codefeedback
You are tasked with creating a Django view that handles both GET and POST requests for a simple form submission. Your view should render an HTML template containing a form on a GET request and process the form data on a POST request. The form should contain fields for a user's name and email address. Upon successful fo...
codefeedback
You are working on a power system optimization model that includes sub-hourly energy adjustments and expressions for delivering energy to provide upward reserves. The code snippet provided is part of a larger optimization model and includes a function call and an expression rule definition. Your task is to implement th...
codefeedback
You are tasked with implementing a service for managing links in a web application. The `LinkService` class is responsible for handling operations related to links, such as adding, removing, and retrieving links. The service should be designed to be a singleton and should be provided at the root level of the applicatio...
codefeedback
You are tasked with implementing a function to normalize the alignment of a read sequence to a reference sequence. The alignment is represented by the `alignment` structure, and the function `normalize_alignment` takes in the alignment object, the read sequence, and the reference sequence as input parameters. The `ali...
codefeedback
You are tasked with implementing a function that divides a given sequence into a specified number of chunks. The function should evenly distribute the elements of the sequence into the chunks as much as possible. If the number of elements in the sequence is not evenly divisible by the number of chunks, the remaining el...
codefeedback
You are tasked with creating a Python program to monitor and collect metrics from various services using Prometheus. Your goal is to implement a class that sets up a TCP server to expose the collected metrics for scraping by Prometheus. You are provided with a code snippet that sets up a TCP server using the `web.TCPS...
codefeedback
You are tasked with creating a program that simulates a simplified version of a package manager's update process. The program should take a list of packages and their update status as input and then execute the update process based on the provided information. You are given the following code snippet as a starting poi...
codefeedback
You are tasked with implementing a Python class that provides debugging functionality using the Python Debugger (Pdb). Your task is to complete the implementation of the `Debugger` class by adding a method that allows setting a breakpoint at a specific line number in a given file. Your task is to implement the `set_br...
codefeedback
You are working on a Laravel application that manages financial data for different users. The application includes a model called "Access" which represents access rights for various financial reports. The code snippet provided is a part of the "Access" model class. The model is associated with a database table named "A...
codefeedback
You are tasked with implementing a Python function that manipulates the system path and loads a specific module. The function should insert a given directory at the beginning of the system path and then import a module from that directory. Your task is to complete the implementation of the function `load_and_import_mod...
codefeedback
You are tasked with implementing a function to convert a given decimal number into its Chinese representation. The provided code snippet contains a method `ConvertToChinese` which takes a decimal number as input and returns its Chinese representation as a string. The Chinese representation of a number follows a specif...
codefeedback
You are tasked with implementing a function to explode a JSON column in a DataFrame based on a given JSON schema. The function should take an input DataFrame, the name of the JSON column, and the JSON schema as input, and return a new DataFrame with the JSON column exploded into separate columns based on the schema. Y...
codefeedback
You are tasked with implementing a Python function that processes command-line arguments and launches a training script for a machine learning model. The function should take in the arguments and execute the training script with the specified parameters. Your task is to complete the function `train_model` by parsing th...
codefeedback
You are tasked with implementing a cloud polling scheduler that interacts with a MongoDB database. The scheduler is responsible for managing and executing cloud polling schedules. The provided code snippet defines a class `CloudPollingScheduler` that inherits from `MongoScheduler` and sets the `Model` attribute to `Clo...
codefeedback
You are tasked with implementing a function that embeds a child view controller into a parent view controller. The function should handle various scenarios and ensure the proper addition of the child view controller's view to the parent's view hierarchy. Write a function `embedChildViewController` that takes in the fo...
codefeedback
You are tasked with implementing a scoring system for a sports event. The scoring system involves tracking the onset times of events, comparing them against predefined thresholds, and assigning scores based on the comparison results. You are given the following code snippet as a starting point: ```cpp using OnsetTime...
codefeedback
You are tasked with creating a program that simulates a simple game of dice. The game involves rolling two dice and calculating the sum of their values. The program should allow the user to input the number of times they want to roll the dice and then simulate the rolls accordingly. After all the rolls are completed, t...
codefeedback
You are tasked with creating a script to automate the generation of icon files in various sizes using Inkscape, a popular vector graphics editor. Inkscape can be run in shell mode to execute commands and perform tasks without the need for a graphical user interface. Your task is to write a script that takes a list of ...
codefeedback
You are tasked with creating a Java program that interacts with Apache ZooKeeper using the Curator framework. Your program should connect to a ZooKeeper server, create a znode with some data, and then retrieve and display the data from the znode. Your program should perform the following steps: 1. Create a CuratorFram...
codefeedback
You are tasked with implementing a resource synchronization system for a multiplayer online game. The game server needs to ensure that all connected clients have the latest game resources, such as maps, textures, and sound files. To achieve this, you need to design a program that can efficiently synchronize the game re...
codefeedback
You are tasked with creating a Python function that analyzes the trend of a given city's data and predicts future values using linear regression. The function should take the city name as input and return the slope of the linear regression model and the predicted value for the given city. The function should perform t...
codefeedback
You are tasked with creating a program to calculate the total fuel required for a set of modules on a spacecraft. Each module has a specific mass, and the fuel required to launch a module is based on its mass. However, the fuel itself also has mass, which must be taken into account when calculating the total fuel requi...
codefeedback
You are tasked with creating a Rust program that simulates a simplified version control system. Your program should take input from the standard input, execute a command using a child process, capture the output of the command, and then create a temporary Git repository in which the command's output will be stored. Yo...
codefeedback
You are given a 2D array representing a grid of cells. Each cell has a unique flat index, which is a single integer representing its position in a flattened version of the grid. The flat index starts from 1 and increases row by row. For example, in a 3x3 grid, the flat indices would be 1, 2, 3, 4, 5, 6, 7, 8, 9. Write...
codefeedback
You are tasked with implementing a visitor pattern for a simple expression tree in C++. The expression tree consists of four types of nodes: `gencode_node`, `expand_node`, `add_node`, and `load_node`. Each node type has a corresponding visitor method that needs to be implemented. The visitor pattern allows adding new o...
codefeedback
You are given a sequence of bytes representing a bitmap image. Each byte represents 8 pixels, with the bits in the byte indicating whether the corresponding pixel is set (1) or unset (0). The bytes are arranged in rows, and each row is represented by a sequence of bytes. Your task is to write a function that takes this...
codefeedback
You are tasked with creating a Rust function that downloads a file from a given URL and saves it to a specified file path. Your function should handle potential errors during the download and file saving process. You are provided with the following code snippet as a reference: ```rust use std::fs::File; use std::io::...
codefeedback
You are tasked with implementing a script that processes a given file path and extracts the directory name from it. The script should handle both absolute and relative file paths and output the extracted directory name. Write a function or script that takes a file path as input and returns the directory name. The dire...
codefeedback
You are tasked with implementing a Python function that can handle different data types for a specific operation. The function should be able to cast the input value to the appropriate data type based on a given parameter. Your task is to create a function `handle_casting` that takes two parameters: `value` and `cast_t...
codefeedback
You are tasked with creating a Python function that processes user input from a web form and saves the user's information into a database using Django's ORM. The function should take the user's first name, last name, email, username, password, user ID, and user role as input and then create a new user object in the dat...
codefeedback
You are tasked with creating a Python function that evaluates a machine learning model using a custom evaluation metric. The function takes in a dataset and a trained model, and it should calculate the evaluation metric for the model's predictions on the dataset. The evaluation metric is defined as the mean absolute er...
codefeedback
You are tasked with creating a Rust struct that represents a configuration object for a file synchronization server. The server configuration includes various settings such as snapshot, symlink support, time resolution, and synchronization type. Your goal is to define the struct and implement a method to validate the c...
codefeedback
You are tasked with creating a Rust function to parse and extract information from a financial message encoded in the FIX (Financial Information eXchange) protocol. The given code snippet is a part of a Rust struct definition that represents a field in a FIX message. The field is related to the delivery stream cycle de...
codefeedback
You are given a 2D grid representing a binary image where 1s represent black pixels and 0s represent white pixels. Your task is to write a function that returns the coordinates of the bounding box of the largest black region in the image. The bounding box is represented by the coordinates of its top-left and bottom-rig...
codefeedback
You are tasked with implementing a Python function that processes a list of router prefixes and returns a dictionary containing the count of unique prefixes for each router. The router prefixes are provided in the format `app.include_router(router, prefix="/vector")`, where `router` is the name of the router and `prefi...
codefeedback
You are tasked with implementing a function to convert an image wrapper to a OpenGL texture. The image wrapper is a data structure that holds image data, and the OpenGL texture is a representation of the image suitable for rendering in an OpenGL environment. You are provided with the following code snippet as a starti...
codefeedback
You are tasked with creating a Python function that generates a unique revision ID for a database record. The revision ID should be a combination of the create date and a unique key. The create date should be in the format "YYYY-MM-DD" and the unique key should be a randomly generated alphanumeric string of length 12. ...
codefeedback
You are tasked with creating a Java program that simulates a simple game of rock-paper-scissors. The program should allow a user to input their choice (rock, paper, or scissors) and then generate a random choice for the computer. After both choices are made, the program should determine the winner based on the standard...
codefeedback
You are tasked with implementing a file type detection system based on the provided code snippet. The system should be able to identify the file type of a given file based on its extension, size, and magic bytes. The file type detection system should support the following criteria: - Category: The category of the file...
codefeedback
You are tasked with implementing a simplified version control system for database schema migrations. Your task is to create a Python class that can manage the migration operations for a database schema. The class should be able to handle dependencies between migrations and perform operations such as deleting models and...
codefeedback
You are tasked with implementing a parsing table for a given grammar. The parsing table is a data structure used in parsing algorithms, such as LL(1) or LR(1) parsers, to determine the next action based on the current state and input symbol. The grammar is represented in a structured format, and the parsing table is co...
codefeedback
You are tasked with implementing a Python function that processes data from a CSV file and performs a specific operation on the data. The function should read the CSV file, extract a specific column, and then perform a mathematical operation on the extracted data. Additionally, the function should generate a plot to vi...
codefeedback
You are tasked with implementing a function to manage the weakening of a system's security. The function should take in a list of security levels and a threshold value. The weakening process involves reducing each security level by the threshold value, but ensuring that the resulting level does not fall below zero. If ...
codefeedback
You are tasked with creating a program to analyze the frequency of words in a given text and visualize the results using a bar chart. Your program should remove common English stopwords and punctuation marks from the text before performing the analysis. Additionally, the program should use different line styles for the...
codefeedback
You are tasked with implementing a payment processing system for an e-commerce platform. The system should handle saving payment information and clearing the user's shopping cart after a successful payment. You are provided with a partial code snippet that includes a function signature for saving the payment and cleari...
codefeedback
You are tasked with implementing a sample processor class that processes a batch of sample paths. The sample processor should be able to handle logging and provide the flexibility to apply different processing methods to the sample paths. You are given a Python code snippet that defines a class `MetaSampleProcessor` w...
codefeedback
You are tasked with implementing a point selection algorithm for a data structure that organizes points in a hierarchical manner. The given code snippet is part of the algorithm and involves selecting points based on certain conditions. Your task is to complete the implementation of the point selection algorithm based ...
codefeedback
You are tasked with creating a Python script to monitor the disk usage of a system and write the data to a file. Your script should utilize the `psutil` library to gather disk usage information and the `open` function to write this information to a specified file. Additionally, the script should handle exceptions grace...
codefeedback
You are tasked with creating a Python function that simulates the process of reverting database migrations. In the context of this problem, a migration is a way to alter the database schema over time. When reverting a migration, the changes made by a specific migration need to be undone. You are given a class `Databas...
codefeedback
You are tasked with creating a Python class that utilizes the provided code snippet as a starting point. Your task is to extend the functionality of the `HelloSayer` class to incorporate the `get_hello` function. The class should have a method called `say_hello_twice` that utilizes the `say_hello` method to print "Hell...
codefeedback
You are tasked with creating a Java program to simulate a simple data ingestion system that sends data to a Kafka topic. The program should generate a JSON-formatted message and send it to the Kafka topic using a Kafka producer. The JSON message format should be as follows: ``` { "Quality":192, "Timestamp":"%s", "V...
codefeedback
You are tasked with implementing a function to add liquidity to a pool in a decentralized finance (DeFi) platform. The platform uses a smart contract system, and the function `do_add_liquidity` is responsible for adding liquidity to a specific pool. The function takes several parameters including the context `ctx`, a r...
codefeedback